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.Select all days between two dates with Day Name in SQL Server<p>Hey <a class="username" rel="moayyad"> moayyad</a>,</p> <p>Please refer below sample query.</p> <p><span style="text-decoration: underline;"><strong>SQL</strong></span></p> <pre class="brush: sql">DECLARE @startDate DATETIME SET @startDate = &#39;20140101&#39; DECLARE @endDate DATETIME SET @endDate = &#39;20140106&#39; ;WITH dateRange AS ( SELECT [Date] = DATEADD(dd, 1, @startDate) WHERE DATEADD(dd, 1, @startDate) &lt; = @endDate UNION ALL SELECT DATEADD(dd, 1, [Date]) FROM dateRange WHERE DATEADD(dd, 1, [Date]) &lt;= @endDate ) SELECT [Date], DATENAME(dw,[Date]) [DayName] FROM dateRange</pre> <p><strong><span style="text-decoration: underline;">Output</span></strong></p> <table border="1"> <tbody> <tr> <td><strong>Date</strong></td> <td><strong>DayName</strong></td> </tr> <tr> <td>2014-01-02 00:00:00.000</td> <td>Thursday</td> </tr> <tr> <td>2014-01-03 00:00:00.000</td> <td>Friday</td> </tr> <tr> <td>2014-01-04 00:00:00.000</td> <td>Saturday</td> </tr> <tr> <td>2014-01-05 00:00:00.000</td> <td>Sunday</td> </tr> <tr> <td>2014-01-06 00:00:00.000</td> <td>Monday</td> </tr> </tbody> </table> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/608931/Select-all-days-between-two-dates-with-Day-Name-in-SQL-Server/https://www.aspforums.net:443/Threads/608931/Select-all-days-between-two-dates-with-Day-Name-in-SQL-Server/Tue, 18 Dec 2018 03:44:47 GMT