get date of all saturdays in a given year - sql server

后端 未结 2 576
青春惊慌失措
青春惊慌失措 2021-01-11 15:46

I need to get a list of all Saturday dates in a given year.

I\'ve seen an oracle post that goes against a table that had \"fiscal calendar table\" but I haven\'t bee

相关标签:
2条回答
  • 2021-01-11 16:19

    for the year 2010 you can do this

    declare @d datetime
    select @d = '20100101'  --'20090101'  if you want 2009 etc etc
    
    select dateadd(dd,number,@d) from master..spt_values
    where type = 'p'
    and year(dateadd(dd,number,@d))=year(@d)
    and DATEPART(dw,dateadd(dd,number,@d)) = 7
    
    0 讨论(0)
  • 2021-01-11 16:24

    declare @d datetime select @d = '20100101' --'20090101' if you want 2009 etc etc

    select dateadd(dd,number,@d) from master..spt_values where type = 'p' and datename(weekday, (dateadd(dd, number, @d))) in ('Saturday', 'Tuesday' /* Specify Day Name */)

    0 讨论(0)
提交回复
热议问题