SQLSERVER函数判断当天是星期几


可以使用两个函数来判断:

select getdate(),datename(weekday,getdate()),datepart(weekday,getdate())

datename 返回星期名称;

datepart 返回数值;

例子:

select  
case   datepart(dw,getdate())
when   1   then   '星期天 '
when   2   then   '星期一 '
when   3   then   '星期二 '
when   4   then   '星期三 '
when   5   then   '星期四 '
when   6   then   '星期五 '
when   7   then   '星期六 '
end


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM