ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Add days to Date excluding Weekends in SQL Server<p>I have tried below sql code. Please check.</p> <pre class="brush: sql">declare @d1 datetime, @d2 datetime declare @daydiff int declare @CalendarDate datetime select @d1 = &#39;08/04/2019&#39; select @CalendarDate = DATEADD(day,25,@d1) set @d2 = DATEADD(Day,35,@d1) -- 25days - 35 , 27days - 38, --select @d2 as BusinessDate select @daydiff = datediff(dd, @d1, @d2) - (datediff(wk, @d1, @d2) * 2) - --- this returns skipped week off days case when datepart(dw, @d1) = 1 then 1 else 0 end + case when datepart(dw, @d2) = 1 then 1 else 0 end --select @daydiff as WorkingDays --condition if(DATEPART(dw,@d2)=1) BEGIN set @d2=DATEADD(day,1,@d2) END else if (DATEPART(dw,@d2)=7) BEGIN set @d2=DATEADD(day,2,@d2) END select @d2 as Businessdate,@CalendarDate as CalendarDate</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/434918/Add-days-to-Date-excluding-Weekends-in-SQL-Server/https://www.aspforums.net:443/Threads/434918/Add-days-to-Date-excluding-Weekends-in-SQL-Server/Sun, 04 Aug 2019 23:51:05 GMT