• ZZartin (12/7/2016)


    The logic shouldn't be too complicated add your normal filter in the where clause for the start and end dates which it sounds like you already have then add another filter that looks something like

    AND DATEDIFF(hour, DATEADD(day, 0, DATEDIFF(day, 0, CALL_DATE_TIME)), CALL_DATE_TIME) >= 8 AND DATEDIFF(hour, DATEADD(day, 0, DATEDIFF(day, 0, CALL_DATE_TIME)), CALL_DATE_TIME) < 17

    Depending on the volume of calls there might be some performance tweeking that would need to be done.

    So much code when you're only need this:

    DATEPART(HH, MyDatetime)

    Either way, that would return incorrect results. I'll let you figure out why.;-)

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2