Hi
I'm trying to make a grouping by hour.
The date is set as an integer, but that conversion is fine.
I would like output like this
Day Amount
01-01-2010 10
02-01-2010 12
03-01-2010 9
In ORACLE something like this
I've managede to do it in months
But apparently there is no HOUR keyword.
Hope someone can help.
/Lhg
I'm trying to make a grouping by hour.
The date is set as an integer, but that conversion is fine.
I would like output like this
Day Amount
01-01-2010 10
02-01-2010 12
03-01-2010 9
In ORACLE something like this
Code:
SELECT to_char(date, 'yyyy-mm-dd hh24') "Dato",
COUNT(*)
FROM table
GROUP BY to_char(date, 'yyyy-mm-dd hh24')
I've managede to do it in months
Code:
SELECT
MONTH(CONVERT(VARCHAR, DATEADD(ss, create_date - DATEDIFF(ss, GETDATE(), GETUTCDATE()), '1970-01-01 00:00'), 120)) AS MONTH,
count(*) AS Antal
from table
where CONVERT(VARCHAR, DATEADD(ss, create_date - DATEDIFF(ss, GETDATE(), GETUTCDATE()), '1970-01-01 00:00'), 120)> dateadd(hh,-168,getdate())
GROUP BY MONTH(CONVERT(VARCHAR, DATEADD(ss, create_date - DATEDIFF(ss, GETDATE(), GETUTCDATE()), '1970-01-01 00:00'), 120))
But apparently there is no HOUR keyword.
Hope someone can help.
/Lhg