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 |
|
paultervit
Starting Member
10 Posts |
Posted - 2008-07-23 : 05:11:38
|
| Hello AllCan someone tell me if there is a function similar to Date for Hour. i.e. I have a table with time entries and I would like to group these by day then hour. For Day I can user Day(date_time). Is there anything similar I can use for hour?ThanksPaul |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-23 : 05:14:08
|
| select dateadd(hh,datediff(hh,0,yourdatefield),0),agregatedfieldsfrom yourtablegroup by dateadd(hh,datediff(hh,0,yourdatefield),0) |
 |
|
|
paultervit
Starting Member
10 Posts |
Posted - 2008-07-23 : 05:19:47
|
| thanks |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-07-23 : 05:22:28
|
quote: Originally posted by visakh16 select dateadd(hh,datediff(hh,0,yourdatefield),0),agregatedfieldsfrom yourtablegroup by dateadd(hh,datediff(hh,0,yourdatefield),0)
Just for clarity I use hour in instead of hh MadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-23 : 05:33:27
|
quote: Originally posted by madhivanan
quote: Originally posted by visakh16 select dateadd(hh,datediff(hh,0,yourdatefield),0),agregatedfieldsfrom yourtablegroup by dateadd(hh,datediff(hh,0,yourdatefield),0)
Just for clarity I use hour in instead of hh MadhivananFailing to plan is Planning to fail
yup...you can use hour or hh i prefer using short form |
 |
|
|
|
|
|
|
|