我正试图将周末的日期从周六改为周日,下面是我的代码。
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))
实际输出 需要