获取给定年份中所有星期六的日期 - sql server [英] get date of all saturdays in a given year - sql server

查看:23
本文介绍了获取给定年份中所有星期六的日期 - sql server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取给定年份中所有星期六日期的列表.

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

我曾看到过一篇与具有财政日历表"的表格背道而驰的 oracle 帖子,但我无法成功转换它,也没有包含我想要调查的一组日期的表格.

I've seen an oracle post that goes against a table that had "fiscal calendar table" but I haven't been able to succeed in converting it nor do I have a table that contains a set of dates I want to investigate.

SELECT DATE DATES,TO_CHAR(DATE,'DAY') DAYS FROM FISCAL_CALENDAR
WHERE DATE_YEAR = 2009 AND
DATE BETWEEN TRUNC(SYSDATE,'YEAR') AND
ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),12) -1 AND
TRIM(TO_CHAR(DATE,'DAY')) = 'SUNDAY'

是甲骨文(例如周日和 2009 年)

was the Oracle (it was for Sunday and 2009 eg)

非常感谢.-汤姆

推荐答案

对于 2010 年,您可以这样做

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

这篇关于获取给定年份中所有星期六的日期 - sql server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆