Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 14, 2012 06:41 PM by clevesteve
Nov 14, 2012 06:07 PM|LINK
I need to find all issues register between 7PM and 7 AM everyday. I have datetime field but at midnght date will change so, i am not sure how to get this done.
can someone help please?
Nov 14, 2012 06:23 PM|LINK
Something like this;
declare @theDate as Date
declare @startDateTime as DateTime
declare@stopDateTime as DateTime
set @theDate = somedate
set @startDateTime = DateAdd(hour, 19, @theDate)
set @endDateTime = DateAdd(hour, 12, @StartDateTime)
where yourDateField between @StartDateTime and @endDateTime
Nov 14, 2012 06:41 PM|LINK
COUNT(calltime + 5/24) CALLS,
CAST(FLOOR(CAST((calltime + 5/24) AS float)) AS datetime) Theday
WHERE DATEPART(HH,calltime + 5/24) <= 12
GROUP BY CAST(FLOOR(CAST((calltime + 5/24) AS float)) AS datetime)
ORDER BY Theday
Just for clarity, this will group the number of calls from 7pm to 7am by the "second" date (the date the midnight to 7am calls were on).