Calculating Work-Days in T-SQL
Posted by Viral Sarvaiya on May 3, 2010
One of the more serious questions in project scheduling, employee planning, and accounting of time is “How many workdays are there?” In other words, given a start date and an end date, how many weekdays (usually a “workday”) are there in the date range including the start date and the end date?
The normal response I get to that question varies but has been limited to “It can’t be done in SQL”, “Ya gotta use a CURSOR”, or “You have to build a table”. This article will take you through all of the logic behind building a nasty fast “Work Day Calculator” function, the crux of which is a single SELECT statement. A fully commented production-worthy UDF is available at the end of this article.
For more details :
This entry was posted on May 3, 2010 at 2:33 PM and is filed under Sql Server. Tagged: advanced querying, Calculating Work-Days in T-SQL, T SQL. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.