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 (Saturday and Sunday) using While loop in SQL Server<p>Hi&nbsp;<a class="username" rel="Waghmare">Waghmare,</a></p> <p>Check with the below query.</p> <p><strong><span style="text-decoration: underline;">SQL</span></strong></p> <pre class="brush: sql">DECLARE @d1 DATETIME DECLARE @BusinessDate_27day DATETIME &nbsp; SET @d1 =&nbsp; &#39;08/04/2019&#39; DECLARE @count INT = 0 WHILE @count &lt; 27 Begin &nbsp;&nbsp;&nbsp; SET @count = @count + 1 &nbsp;&nbsp;&nbsp; SET @BusinessDate_27day = DATEADD(DAY,1,@d1) &nbsp;&nbsp;&nbsp; SET @d1 = @BusinessDate_27day &nbsp;&nbsp;&nbsp; IF DATEPART(WEEKDAY,@d1) =&nbsp; 1 OR DATEPART(WEEKDAY,@d1) =&nbsp; 7 &nbsp;&nbsp;&nbsp; BEGIN &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET @count = @count - 1 &nbsp;&nbsp;&nbsp; END END &nbsp; SELECT @BusinessDate_27day AS Businessdate</pre> <p><strong><span style="text-decoration: underline;">Output</span></strong></p> <p>10.09.2019</p>https://www.aspforums.net:443/Threads/135402/Add-Days-to-Date-excluding-Weekends-Saturday-and-Sunday-using-While-loop-in-SQL-Server/https://www.aspforums.net:443/Threads/135402/Add-Days-to-Date-excluding-Weekends-Saturday-and-Sunday-using-While-loop-in-SQL-Server/Tue, 06 Aug 2019 02:17:33 GMT