Home Forums SQL Server 2008 SQL Server 2008 - General How to group time into a range like 9:00-10:00 AM,10:00-11:AM etc in SSRS charts??? RE: How to group time into a range like 9:00-10:00 AM,10:00-11:AM etc in SSRS charts???

  • If you're using a DATETIME, you can use the DATEPART function to get the hour and group on the value for the hour based on a 24 hour clock.

    DATEPART(hh, GETDATE())

    You could then group on the hour number and use some kind of CASE statement to give it a pretty name

    CASE

    ...

    WHEN DATEPART(hh, GETDATE()) = 14 THEN '2:00pm-3:00pm'

    WHEN DATEPART(hh, GETDATE()) = 15 THEN '3:00pm-4:00pm'

    ...

    END

    Hope that helps.

    John