Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
359 views
in Technique[技术] by (71.8m points)

sql - 获取SQL Server 2005/2008中的星期几(Get day of week in SQL Server 2005/2008)

If I have a date 01/01/2009, I want to find out what day it was eg Monday, Tuesday, etc...

(如果我有一个日期01/01/2009,我想知道它是什么日子,例如周一,周二等...)

Is there a built-in function for this in SQL Server 2005/2008?

(SQL Server 2005/2008中是否有内置函数?)

Or do I need to use an auxiliary table?

(或者我需要使用辅助表吗?)

  ask by translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use DATENAME or DATEPART :

(使用DATENAMEDATEPART :)

SELECT DATENAME(dw,GETDATE()) -- Friday
SELECT DATEPART(dw,GETDATE()) -- 6

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...