Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Generate a Range of Dates - SQL Server

RSS
Modified on Tue, Oct 08, 2019, 6:54 AM by Administrator Categorized as SQL Server
declare
     @dt1 date = '2000-01-01'
    ,@dt2 date = '2027-01-01'

;with cte as (
    select dt = @dt1
    union all
    select dt = dateadd(dd, 1, dt) from cte where dt < @dt2
    )
select 
     Dt
from 
    cte
order by
    Dt
option 
    (maxrecursion 1000)

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.