Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count by Hour

Status
Not open for further replies.

IanWaterman

Programmer
Joined
Jun 26, 2002
Messages
3,511
Location
GB
I was hoping there was a function like MONTH, whereby I can get the Hour from a datetime field.

I want to run a query like this

select count(recordNo), hour(Start_Date_Time)
from call_details_001
where arrival_queue_unique_ref = 'QUE100043'
and Start_Date_Time >= {ts '2010-04-01 00:00:00'} AND Start_Date_Time <{ts '2010-05-01 00:00:00'}
group by hour(Start_Date_Time)
order by hour(Start_Date_Time)

Where the non existent function HOUR is replaced by some code to find hours.

Thank you

Ian

 
Having now serached this forum found answer.

select count(recordNo), datepart(hour, Start_Date_Time)
from call_details_001
where arrival_queue_unique_ref = 'QUE100043'
and Start_Date_Time >= {ts '2010-04-01 00:00:00'} AND Start_Date_Time <{ts '2010-05-01 00:00:00'}
group by datepart(hour, Start_Date_Time)
order by datepart(hour, Start_Date_Time)

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top