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 2005 Forums
 Transact-SQL (2005)
 Sort by date-only(not time) and then another field

Author  Topic 

zsdave
Starting Member

4 Posts

Posted - 2009-08-10 : 14:42:33
I am trying to create a report for some attorneys that will sort their court appearances by the date of the trial and then by the county. Even though I try to format the date field to not include the time its as if its still there. So whats currently happening is it sorts by the day, but it breaks up the county by the time the actual trial is in the datetime field.

Monday
County A - 8:30
County A - 9:00
County B - 10:00
County A - 10:30

What I would like is something like this...

Monday
County A - 8:30
County A - 9:00
County A - 10:30
County B - 10:00

Any help would be greatly appreciated

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-10 : 15:21:15
assuming your trial date column is a DATETIME datatype here is one way:

order by dateadd(day, datediff(day, 0, <TrialDateCol>), 0), [County]

Be One with the Optimizer
TG
Go to Top of Page

zsdave
Starting Member

4 Posts

Posted - 2009-08-10 : 15:34:53
That got it, thank you very much TG!
Go to Top of Page
   

- Advertisement -