尝试从一些日期列中将周末日期定为星期日

时间:2019-07-17 07:36:41

标签: sql sql-server tsql

我正试图将周末的日期从周六改为周日,下面是我的代码。

CREATE VIEW  [CustomerServiceDatabase].[Counts_NS3] AS
select "Fund Code","Sent to Auditor","Sent to Trustees","Tax Return Lodged","Tax Year End",
DATEPART(WK,"Sent to Auditor") AS W_A,
DATEPART(year,"Sent to Auditor") AS Y_A,
DATEPART(WK,"Sent to Trustees") AS W_T,
MAX(CASE WHEN DATEPART(WEEK,"Sent to Auditor" ) = DATEPART(WEEK, DATEADD(DAY, -1, DATEADD(YEAR, DATEDIFF(YEAR, 0, "Sent to Auditor") + 1, 0))) THEN DATEADD(DAY, -1, DATEADD(YEAR, DATEDIFF(YEAR, 0, "Sent to Auditor") + 1, 0)) 

实际输出 enter image description here 需要 server

0 个答案:

没有答案