Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Selecting and Ordering the date in a datetime field

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-05 : 15:10:12
sher writes "I am using this SQl statement to grab the Distinct date and just the dates from a field 'eventdate' containing dates and time.

"SELECT DISTINCT CONVERT(char(12), eventdate, 101) as eventdate FROM assignment WHERE Active = 1 ORDER BY CONVERT(char(12), eventdate, 101) DESC"

There are multiple entries for each date each with different times attached to them. I only want one of each date and I only want the date. If I don't convert it in the SQL statement I will get many of each date because the time attached to them is different therefore each entry is distinct. The above statement works except for the Order By. They get sorted as strings instead of dates so all of the january's are at the bottom (01) regardless of the year. I want them sorted as dates. Any help is appreciated.

Thanks
*~Sher"
   

- Advertisement -