我正在收集一些数据,每月跟踪一次,并试图按周进行总结。我遇到的问题是星期六星期五,而不是正常的星期天星期六。
当前代码为:
SELECT DISTINCT
C.[Incident ID]
, C.[Assignment Group]
, C.Priority
, C.Area
, C.[Sub-area]
, C.Manager
, C.AVP
, (CAST(convert(varchar(25),C.[Opened Time],101) as varchar(30))
+ ' '
+ CAST(convert(varchar(25),C.[Opened Time],108) as varchar(30))) as [Opened Time]
, (CAST(convert(varchar(25),C.[Closed Time],101) as varchar(30))
+ ' '
+ CAST(convert(varchar(25),C.[Closed Time],108) as varchar(30))) as [Closed Time]
, M.MgmtLevel1 as [Manager Name]
, C.[TTR Days] as [TTR Days]
, C.[TTR Hours] as [TTR Hours]
, CAST(convert(varchar(25),C.[Closed Time],101) as varchar(30)) as [Closed Date]
, DATEADD(week, DATEDIFF(week,DATEADD(day, 4, 0), [Closed Time]) , +4) as [Week]
FROM Common.vwIncident C,Vanilla.vwGeneral_Assignment V,
Common.vwcontact_byworkgroupformanagementprogression M
WHERE
V.[wdmanagername] = M.Mgr
AND mgmtlevel3_id = 'MIJGP'
AND C.[Assignment Group] = V.[Name]
AND DATEDIFF(month, [Closed Time], getdate()) = 1
这将返回我要查找的正确的“周末”日期,但是,它将指定从星期六开始的记录包含在星期五结束的一周中。
例如,一些输出如下:
我需要从输出中得到的是将“关闭日期”分配到周六-周五工作周之后的适当“周”。
有什么建议吗?
暂无答案!
目前还没有任何答案,快来回答吧!