Check out datepart.

-----Original Message-----
From: Robert Rawlins - Think Blue
[mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 01, 2007 7:42 AM
To: CF-Talk
Subject: Group By Hours

Hello Guys,

 

I have a bunch of records of log data, all with a datetime stamp on it,
and I'm looking to have SQL Server return them grouped into hours. I've
done this before using MySQL I think, using the Hour() function in the
query but it would seem that SQL Server doesn't support such a function.
The table looks something like this.

 

LogID     ClassID                  DateTime

1              1                              01/01/2007 00:01:25

2              1                              01/01/2007 00:01:27

3              1                              01/01/2007 00:01:28

4              1                              01/01/2007 00:01:28

5              2                              01/01/2007 00:01:30

6              1                              01/01/2007 00:02:01

7              2                              01/01/2007 00:02:25

8              1                              01/01/2007 00:03:40

9              2                              01/01/2007 00:03:55

 

Any idea on the best way to do this? There could be tones of records per
hour you see, and it makes it much simpler to table and chart if they're
grouped into hours. I'd also like to perform a count for the number of
each type if 'class' there was for each hour, so when outputting the
data it looks something like this.

 

Date/Time                          Class 1                   Class 2

01/01/2007 00                    6                              3

 

Make sense?

 

Thanks for any help guys,

 

Rob





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 by AdobeĀ®
Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7. 
Free Trial. http://www.adobe.com/products/coldfusion?sdid=RVJV

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276602
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to