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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 DateDiff()

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-10-10 : 07:59:53
Hector writes "I don't think this should be a hard question but I can't seem to find the answer anywhere. I'm looking for a variation on the DateDiff() function. I need a function that would use only a work day calendar giving the DateDiff and not taking Saturdays, Sundays and Major Holidays into account."

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-10-10 : 08:48:30
Use the search functionality. Search for "weekday".

Jay White
{0}
Go to Top of Page

drymchaser
Aged Yak Warrior

552 Posts

Posted - 2003-10-10 : 08:53:48
Hector, there isn't any built-in function in SQL for this issue. However you could build one for Saturdays and Sundays using DATEPART(), but for Holidays no such luck. The solution many people have used is a table of days in the year with sequential numbers and workday/nonworkday indicators.

It would be something similar to this
DayNum	Date		IsWorkday
------ ---------- ---------
1 01/01/2003 0
2 01/02/2003 1
....

Or I have seen them where only workdays were included in the table.
Go to Top of Page
   

- Advertisement -