Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I have stored date-time as string in table in this format YYYYMMDDHHMM ... example200902252353I want tome make query, something like thisSELECT COUNT(id) AS Counter, MIN(TimeOut) As TimeIn, SUBSTRING(TimeOut,8,2) AS [HRO] WHERE TimeIn > '200901010000'GROUP BY [HRO]So, I need to count visits by hour. I also need date of that grouping and week.
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2009-02-25 : 10:33:30
something like
SELECT COUNT(id) AS Counter, MIN(TimeOut) As TimeIn,CONVERT(datetime,LEFT(TimeOut,8),112) AS date, SUBSTRING(TimeOut,9,2)*1 AS hoursWHERE TimeIn > '2009-01-01 00:00:00'GROUP BY CONVERT(datetime,LEFT(TimeOut,8),112),SUBSTRING(TimeOut,9,2)*1