January 27, 2009 at 10:49 am
I have data like this in one column and want to get the data by hour for 24 hours. how can i get it. I am trying to get date add (hour) but not working. the data is datetime and there is record for each second as you can see in this sample data!! Need to combine for the records for each hour
2009-01-22 21:57:04.767
2009-01-22 21:57:04.767
2009-01-22 21:57:04.767
2009-01-22 21:57:04.767
2009-01-22 21:57:04.767
2009-01-22 21:57:04.767
2009-01-22 21:57:04.767
2009-01-22 21:57:04.767
2009-01-22 21:57:04.767
2009-01-22 21:57:04.767
2009-01-22 21:57:04.767
2009-01-22 21:57:04.767
2009-01-22 21:57:04.767
2009-01-22 21:57:04.767
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:58:21.450
2009-01-22 21:59:44.900
2009-01-22 21:59:44.900
2009-01-22 21:59:44.900
2009-01-22 21:59:44.900
2009-01-22 21:59:44.900
2009-01-22 21:59:44.900
2009-01-22 21:59:44.900
2009-01-22 21:59:44.900
2009-01-22 21:59:44.900
2009-01-22 21:59:44.900
2009-01-22 21:59:44.900
2009-01-22 21:59:44.900
2009-01-22 21:59:44.900
2009-01-22 21:59:44.900
January 27, 2009 at 10:56 am
SELECT CONVERT(VARCHAR,@YOURDATECOLUMN,101),HOUR(YOURDATECOLUMN)
FROM YOURTABLE
group by CONVERT(VARCHAR,@YOURDATECOLUMN,101),HOUR(YOURDATECOLUMN)
Lowell
January 27, 2009 at 10:57 am
select convert( char(8), datecolumn, 112) dt, datepart( hour , datecolumn) as hr, count(*) cnt
from table
group by convert( char(8), datecolumn, 112) , datepart( hour, datecolumn)
* Noel
January 27, 2009 at 10:58 am
Hehe Lowell beat me to it :d
* Noel
January 27, 2009 at 11:07 am
lol I'm on the ball today...rare for me
Lowell
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply