Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grouping by hours
Message
From
01/02/2010 18:05:08
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Grouping by hours
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01447023
Message ID:
01447023
Views:
100
I thought the following would work to group by hours by it is not:
SELECT CONVERT(CHAR(4),YEAR(Hit.AddDate))+REPLACE(STR(MONTH(Hit.AddDate),2),' ','0')+
REPLACE(STR(DAY(Hit.AddDate),2),' ','0')+REPLACE(STR(HOUR(Hit.AddDate),2),' ','0') AS lcChampNumero,
COUNT(*) AS Compte,MIN(Hit.AddDate) AS AddDate 
FROM Hit (NOLOCK) 
 GROUP BY CONVERT(CHAR(4),YEAR(Hit.AddDate))+REPLACE(STR(MONTH(Hit.AddDate),2),' ','0')+
 REPLACE(STR(DAY(Hit.AddDate),2),' ','0')+REPLACE(STR(HOUR(Hit.AddDate),2),' ','0') ORDER BY 1 DESC 
The Hour is not a recognized built-in function name.

What can I do?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform