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.
Author |
Topic |
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2008-02-28 : 04:21:02
|
i have a queryselect mydate,lastname from users group by mydate,lastnamenow the only thing is mydate is a datetime fields but i want the results to group by just the date for each lastname entered.How do i do this? |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-02-28 : 04:23:22
|
select dateadd(day, datediff(day, '19000101', mydate), '19000101') AS theDay ,lastname from users group by dateadd(day, datediff(day, '19000101', mydate), '19000101'),lastname E 12°55'05.25"N 56°04'39.16" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-28 : 04:31:53
|
orselect dateadd(day, datediff(day, 0, mydate), 0) AS mydate ,lastname from users group by dateadd(day, datediff(day, 0, mydate), 0),lastnameMadhivananFailing to plan is Planning to fail |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-02-28 : 04:54:16
|
or select dateadd(day, datediff(day, '99991231', mydate), '99991231') AS theDay ,lastname from users group by dateadd(day, datediff(day, '99991231', mydate), '99991231'),lastnameI just use '19000101' for clarification since BOL states the 2nd and 3rd parameter to be dates.Not many beginners will notice that 0 is the same as '19000101' because of internal conversion. E 12°55'05.25"N 56°04'39.16" |
|
|
|
|
|
|
|