Time between dates in business hours

  • Anyone have a good function or method for returning the number of business hours (or minutes) between two dates? I found this article and wondered how others do it.

    http://www.sqlservercentral.com/scripts/Miscellaneous/31471/

  • Hi there,

    Hi there,

    This isn't the exact answert but i hope it helps

    For 8 working hours per day...

    SELECT DATEDIFF(mm,GETDATE(),'12/12/12') * 8

    If your talking about Monday-Friday only, that's a different query

    It would be better if you could show us some sample data and some sample output. Thanks

    _____________________________________________
    [font="Comic Sans MS"]Quatrei Quorizawa[/font]
    :):D:P;):w00t::cool::hehe:
    MABUHAY PHILIPPINES!

    "Press any key...
    Where the heck is the any key?
    hmmm... Let's see... there's ESC, CTRL, Page Up...
    but no any key"
    - Homer Simpson
  • Agree with Quatrei.X, sample data would be better, but check this out too and see if it helps -

    http://www.sqlservercentral.com/articles/Advanced+Querying/calculatingworkdays/1660/

    Lots of questions when you start looking at workdays/hours/such, since holidays differ depending on your location, etc. (see the discussion of the above for examples)

    Now, are we talking DBA hours per day, or management hours? 😛

    ---------------------------------------------------------
    How best to post your question[/url]
    How to post performance problems[/url]
    Tally Table:What it is and how it replaces a loop[/url]

    "stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply