views:

44

answers:

1

I'm currently using a select statement with one column as DATEPART(hh, CallTime) AS Hour and then doing:

GROUP BY DATEPART(hh, CallTime) 
ORDER BY Hour

This displays the hours starting at midnight and going through midnight - how would I go about having this go from noon to noon? Thanks!

+3  A: 

CASE WHEN (DATEPART(hh, CallTime) >=12) THEN DATEPART(hh, CallTime) - 12 ELSE DATEPART(hh, CallTime)+12 END AS hour_since_noon should do it if I understood your question correctly.

You may want to have 2 separate fields, your original one to actually display and this one to order

DVK
That gives the hours in the correct format, but they are then still sorted from lowest to highest which results in them still being from midnight to midnight
BarrettJ
Updated now that I got what you were trying to do
DVK
Thanks, works perfect!
BarrettJ