SQL breakdown TIME

This statement will count number of records in a given month and breakdown it every 30 minutes.

select count(ID) as ID_Count, Date_30min from
( select ID, convert(datetime,convert(varchar(14),calldatetimefield,120) + case when datepart(minute,calldatetimefield) < 30 then '00' else '30' end) as date_30min from tablename where calldatetimefield between '2009-02-01 00:00:00.000' and '2009-02-28 23:59:59.997' and ......) d30 group by date_30min order by date_30min DESC [ad#co-1]

You must be logged in to post a comment.