我如何通过Sql Server 2008了解周六和周日 [英] How Do I Know Saturday And Sunday With Sql Server 2008
本文介绍了我如何通过Sql Server 2008了解周六和周日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在sql server
解决方案
的帮助下检查每个星期六和星期日,检查此链接。
http://www.sqlteam.com/forums/topic.asp? TOPIC_ID = 126721 [ ^ ]
http://www.aspdotnet-suresh.com/2010/09/finding-sundays-in-given-month-using.html [ ^ ]
DECLARE @ DesiredDate date = ' 2014-06-28'
SELECT CASE WHEN UPPER(DATENAME(dw, @ DesiredDate ))= ' SUNDAY' OR UPPER(DATENAME(dw, @ DesiredDate ))= ' < span class =code-string> SATURDAY'
那么
' YES'
ELSe
' NO'
END
以下查询为您提供当天的名称[例如:如果我今天给@date它将返回星期二]
SELECT DATENAME(工作日, @ date ) AS ' 工作日
希望这会有所帮助!
问候,
Dinesh Kumar。诉
i want to check the every saturday and sunday of the month with the help of sql server
解决方案
Check this links.
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=126721[^]
http://www.aspdotnet-suresh.com/2010/09/finding-sundays-in-given-month-using.html[^]
DECLARE @DesiredDate date='2014-06-28' SELECT CASE WHEN UPPER(DATENAME(dw, @DesiredDate)) = 'SUNDAY' OR UPPER(DATENAME(dw, @DesiredDate)) = 'SATURDAY' THEN 'YES' ELSe 'NO' END
The below query gives you the name of the day [eg: if I give @date as today it will return "Tuesday"]
SELECT DATENAME(weekday,@date) AS 'Weekday'
Hope this helps!
Regards,
Dinesh Kumar.V.
这篇关于我如何通过Sql Server 2008了解周六和周日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文