Home Forums SQL Server 2012 SQL Server 2012 - T-SQL How to get the date? RE: How to get the date?
Hunchback
SSCrazy
Points: 2649
More actions
March 25, 2014 at 7:13 am
#1699853
Use a ranking function.
with C1 as (
select *, row_number() over(partition by [year], [month] order by dt) as rnk
from calendar
-- exclude weekends and holidays
-- where isweekend = 0 and isholiday = 0
)
select *
from C1
where rnk = 5;