Count weekends between two dates sql server

Count weekends between two dates sql server

Author: AjazoPHONEtine Date: 20.07.2017

Can I calculate there's how many weekend days between two dates in SQL Server? - Stack Overflow

I need to get the number of weekends between dates in sql as a function. I have tried but stuck up somewhere in the logic.

How to Count Work Days Between 2 Dates in SQL Server - CodeProject

You can change the CASE statements depending on how you want to handle cases where the start or end date is in a weekend. In my case I'm not including the weekend if the start or end date is a Saturday or Sunday.

Count days excluding Sundays between two dates in Excel

By posting your answer, you agree to the privacy policy and terms of service. Stack Overflow Questions Developer Jobs Documentation beta Tags Users. Sign up or log in to customize your list.

Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us.

Log In Sign Up. Join the Stack Overflow Community. Stack Overflow is a community of 7. Join them; it only takes a minute: Get number of weekends between two dates in SQL Ask Question. You need to specify what happens when border dates that are overlaping with weekend days.

What happens when you specify saturday and sunday, or friday and saturday, or sunday and sunday? Try replacing the if statement with this: This is dependent on SET DATEFIRST msdn. I tried out this logic with several edge cases and it seems to work. Kenneth Fisher 2, 11 This will give you the number of sunday between two dates SELECT DateDiff ww, dFrom, dTo as NumOfSundays.

count weekends between two dates sql server

Prashant16 1, 2 9 Sign up or log in StackExchange. Sign up using Facebook.

Sign up using Email and Password. Post as a guest Name. Stack Overflow works best with JavaScript enabled. This will give you the number of sunday between two dates SELECT DateDiff ww, dFrom, dTo as NumOfSundays share.

MathOverflow Mathematics Cross Validated stats Theoretical Computer Science Physics Chemistry Biology Computer Science Philosophy more 3. Meta Stack Exchange Stack Apps Area 51 Stack Overflow Talent.

Rating 4,1 stars - 716 reviews
inserted by FC2 system