Retrieve Dates between Selected Particular Dates In SQL Server
In SQL Retrieve the Dates between Selected Particular Dates In SQL Server without using any database in SQL Server.
SQL Code
declare @startdate datetime
,@enddate datetime
set @startdate='7/01/2014';
set @enddate='7/19/2014';
with alldates as
(
select @startdate DateVal
union
all
select DateVal + 1
from alldates
where DateVal + 1 <= @enddate
)
select DateVal
from alldates;
SQL Code
declare @startdate datetime
,@enddate datetime
set @startdate='7/01/2014';
set @enddate='7/19/2014';
with alldates as
(
select @startdate DateVal
union
all
select DateVal + 1
from alldates
where DateVal + 1 <= @enddate
)
select DateVal
from alldates;
Comments
Post a Comment
Thank You for your Comment