Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 get date which is +8 working days from today

Author  Topic 

sedin
Starting Member

2 Posts

Posted - 2012-05-04 : 03:22:31
Hi,
I got this problem. Need get date which is +8 working days from today. Got somebody any idea?

thanks a lot
cheers

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-05-04 : 07:23:28
Does the definition of "working days" include or exclude holidays that do not fall on a Saturday or Sunday? If you want to consider that, you would need a calendar table which can be used to identify the holidays.

Also, can the question be asked even on weekends/holidays, or only on weekdays

If you need to consider only weekends as non-working days, you can implement the logic to exclude weekends and calculate the number of days, but even so it might be easier to use a calendar table.
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-05-04 : 07:28:50
If you want to consider only weekends logic such as this can be used. There may be opportunities to simply this, but the thought process is that, depending on the day of the week on which the question is asked you add 10,11 or 12 days.
SELECT DATEADD(dd,
CASE
WHEN DATEDIFF(dd,'19000101',GETDATE())%7 IN (0,1,6) THEN 10
WHEN DATEDIFF(dd,'19000101',GETDATE())%7 IN (2,3,4) THEN 12
ELSE 11
END, GETDATE());
Go to Top of Page

sedin
Starting Member

2 Posts

Posted - 2012-05-09 : 03:32:20
Thanks sunitabeck, thats works perfectly. Exactly what I need. Dont care about bank holidays, only interested about weekends.

Thanks a lot
cheers
Go to Top of Page
   

- Advertisement -