在一系列日期中仅显示WEEKDAY

时间:2014-04-08 17:23:01

标签: sql date reporting-services

我的SSRS中有以下查询:

SELECT [ARRIVED DATE]
FROM [DSPCONTENT01].[dbo].[zWMGWEEKARRIVAL]
WHERE [ARRIVED DATE] = DATEPART(weekday,CAST([ARRIVED DATE] as float))

应该获取ARRIVED DATE字段并仅显示工作日日期,但我收到Explicit conversion from data type date to float is not allowed

我的到来日期如下:

2014-04-01
2014-04-02
2014-04-03
2014-04-04
2014-04-05
2014-04-06
2014-04-07

如何修改我的脚本,使其仅显示那些日期范围内的工作日。

1 个答案:

答案 0 :(得分:1)

您需要修改where子句以排除星期日和星期六。 SQL服务器默认为星期日开始,因此在这种情况下,以下查询应该适合您。

SELECT [ARRIVED DATE]
FROM [DSPCONTENT01].[dbo].[zWMGWEEKARRIVAL]
WHERE DATEPART(weekday,[Arrived Date]) NOT IN (1,7)