Avatar of Collindsouza
Collindsouza
Flag for United Kingdom of Great Britain and Northern Ireland asked on

IS there a way to find out if the date falls on a weekend

I am trying to do some date manipulations in my stored procedure... For example Current date + 40 days = new date...

However i need to know if this new date falls on a weekend i.e Saturday/Sunday.. if it does then i need to find the immediate working day which falls on a monday

How can i achieve this in my SQL Server stored procedure... i'm using SQL Server 2000...

Thanks in Advance,
Collin
Microsoft SQL Server

Avatar of undefined
Last Comment
imran_fast

8/22/2022 - Mon
Aneesh

IF SELECT DATEPART(dw,GETDATE()) = 7 OR SELECT DATEPART(dw,GETDATE()) = 1
Print 'WeekEnd'
ASKER CERTIFIED SOLUTION
Aneesh

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Lowfatspread

like this...
select dateadd(d,case datepart(dw,target) when 7 then 2
                                         when 1 then 1 else 0 end)  as target
   from (select dateadd(d,+40,getdate()) as target  ) as x


 
imran_fast

for all the suggestion about Make sure about the
DateFirst

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23