Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favourite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved in your SSC briefcase from the favorites tab.
Download now (direct download link)

A different Weekdays Between test

By brendt hess,

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.

Total article views: 108 | Views in the last 30 days: 1
 
Related Articles
FORUM

Getting Weekdays date between a specified date range

Getting Weekdays date between a specified date range

FORUM

TSQL copy data in weekdays

TSQL copy data in weekdays

FORUM

A different Weekdays Between test

Comments posted to this topic are about the item [B]A different Weekdays Between test[/B]

SCRIPT

UDF_GET_NEXT_WEEKDAY

A simple way of getting the next weekday's dates...

Tags
miscellaneous    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones