什么日期基于日期时间

时间:2012-03-29 19:57:18

标签: sql sql-server-2008

是否可以根据以下代码跟踪每天的日期(周一至周日)?

DECLARE @DATA TABLE(
    Movie1 DATETIME,
    Movie2 DATETIME,
    Movie3 DATETIME,
    Movie4 DATETIME,
    Movie5 DATETIME
)
INSERT INTO @DATA
SELECT '01/20/2010','02/15/2010','02/02/2010','03/31/2010','04/16/2010' 

2 个答案:

答案 0 :(得分:2)

如果您问如何退回文字,例如根据日期“星期一”,请查看MSDN上的DATENAME功能。

select datename(weekday, Movie1) from @DATA

答案 1 :(得分:1)

试试这个:

select 
datename(dw, Movie1) Movie1Day,
datename(dw, Movie2) Movie2Day,
datename(dw, Movie3) Movie3Day,
datename(dw, Movie4) Movie4Day,
datename(dw, Movie5) Movie5Day
from @DATA