//dates And Week Numbers Between To Dates
declare @date_from datetime, @date_to datetime
set @date_from = '07/01/2015'
set @date_to = '07/31/2015';
with dates as(
select @date_from as dt
union all
select DATEADD(d,1,dt) from dates where dt<@date_to
)
select datepart(day, datediff(day, 0, dt)/7 * 7)/7 + 1 WeekNo,* from dates
declare @date_from datetime, @date_to datetime
set @date_from = '07/01/2015'
set @date_to = '07/31/2015';
with dates as(
select @date_from as dt
union all
select DATEADD(d,1,dt) from dates where dt<@date_to
)
select datepart(day, datediff(day, 0, dt)/7 * 7)/7 + 1 WeekNo,* from dates
No comments:
Post a Comment