get hourly combine data

  • 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

  • SELECT CONVERT(VARCHAR,@YOURDATECOLUMN,101),HOUR(YOURDATECOLUMN)

    FROM YOURTABLE

    group by CONVERT(VARCHAR,@YOURDATECOLUMN,101),HOUR(YOURDATECOLUMN)

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • 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

  • Hehe Lowell beat me to it :d


    * Noel

  • lol I'm on the ball today...rare for me

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply