Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Weekend

Author  Topic 

mukhan85
Starting Member

46 Posts

Posted - 2009-01-23 : 16:46:34
Hi,
I need to subtract "Start" date from the "End" Date. But I need to exclude weekends. Suppose one job has been started on the Friday and finished on Tuesday, then the difference should return 3 days instead of 5, because I don't need weekends.
I have used the following for finding difference:

DATEDIFF(DAY, DATEADD(second, tm.T1, '1969-12-31 8:00:00 PM'), DATEADD(second, tm.T10, '1969-12-31 8:00:00 PM')))

Thank you.

nathans
Aged Yak Warrior

938 Posts

Posted - 2009-01-23 : 17:15:57
Jeff has a great post on this:

http://weblogs.sqlteam.com/jeffs/archive/2008/07/31/week-days-between-two-dates.aspx



Nathan Skerl
Go to Top of Page

mukhan85
Starting Member

46 Posts

Posted - 2009-01-23 : 17:53:18
quote:
Originally posted by nathans

Jeff has a great post on this:

http://weblogs.sqlteam.com/jeffs/archive/2008/07/31/week-days-between-two-dates.aspx



Nathan Skerl



Great, Thank you very much!
Go to Top of Page

nathans
Aged Yak Warrior

938 Posts

Posted - 2009-01-23 : 18:02:25
no problem, thank Jeff!

Nathan Skerl
Go to Top of Page
   

- Advertisement -