Recently, I answered a question by a person on Experts Exchange.com on how to find the # of weekdays between two dates. This question was simplified greatly by the fact that the dates given would always be from Monday to Friday, and so the calculations needed were very simple.
Then, while looking at the recent scripts listing here on SQL Server Central, I saw Rick Carisse's function for calculating the number of weekdays between two dates, and realized that I really needed to flesh out the basic function to (1) handle the case of the start or end day falling on a weekend, and (2) to handle any Datefirst setting.
This UDF takes a start date and an end date, and returns the # of weekdays falling between them. If the days are the same and a weekday, they return 1 day.
2007-10-02 (first published: 2002-06-20)
15,451 reads