Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Order By time question

Status
Not open for further replies.

bminaeff

Programmer
Joined
Dec 26, 2007
Messages
49
Location
US
Hi all,

I have a requirement where I get a time in "HH:MM AM/PM" format so for example I might get three times of "11:55 AM" , "12:39 AM" and "1:05 PM" sent over to me. I have to log this to a table and sort it in descending order. The problem is that the "1:05 PM" is then placed below the "11:55 AM" record. In my table I have the column set as an nvarchar(50) since my time may also be a string like "Unknown".

Any ideas how to correct this?

Thanks
-Bill
 
If the string is a valid datetime (ISDATE()), order it by Cast(strDate as smalldatetime)

"Artificial Intelligence is no match for Natural Stupidity"
 
That works great, thanks alot genomon
 
SWEET!!
[cheers]

"Artificial Intelligence is no match for Natural Stupidity"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top