Then something similar to what chris said should work. Select Year(myDatefield), Month(myDatefield),... >From YourTable GROUP BY Year(myDatefield), Month(myDatefield)... ORDER BY Year(myDatefield), Month(myDatefield)...
I think you would need to start from large time frame (year) to smallest (hour) to get the groups working. If you are doing all in one query. -----Original Message----- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Thursday, November 01, 2007 2:42 PM To: SQL Subject: Re: MS SQL Server: grouping date-time values Then it is just a slip of the keyboard. I am dealing with a date-time field originally populated with a value created by the CF CreateODBCDateTime() function. I am now wanting to create reports where this data is grouped by various time ranges such as each hour or each day, week, month or year. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Check out the new features and enhancements in the latest product release - download the "What's New PDF" now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/SQL/message.cfm/messageid:2991 Subscription: http://www.houseoffusion.com/groups/SQL/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.6
