Link to home
Start Free TrialLog in
Avatar of Collindsouza
CollindsouzaFlag 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
Avatar of Aneesh
Aneesh
Flag of Canada image

IF SELECT DATEPART(dw,GETDATE()) = 7 OR SELECT DATEPART(dw,GETDATE()) = 1
Print 'WeekEnd'
ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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


 
Avatar of imran_fast
imran_fast

for all the suggestion about Make sure about the
DateFirst