我正在为这个程序而苦苦挣扎。
如果是周一到周四,我希望一切都提前 90 天;
SELECT
PR.ClientID
,PR.NewDealEndDate
INTO
#OriginalRenewalDetails
FROM
Shiva.dbo.ProductRemortgage PR WITH (NOLOCK)
LEFT JOIN Shiva.dbo.ClientLead AS CL WITH (NOLOCK)
ON CONVERT(VARCHAR(50), CL.OriginatorReferenceID) = CONVERT(VARCHAR(50), PR.ClientID)
WHERE -- 90 days from now.
PR.NewDealEndDate = DATEADD(dd, 90, DATEDIFF(dd, 00, GETDATE()))
AND CL.ClientID IS NULL
但是,如果是星期天,我希望在 Where 子句中进行以下更改。这样我也能得到周五和周六的结果。
WHERE -- 90 days from now.
PR.NewDealEndDate BETWEEN DATEADD(dd, 88, DATEDIFF(dd, 00, GETDATE())) AND DATEADD(dd, 90, DATEDIFF(dd, 00, GETDATE()))
AND CL.ClientID IS NULL
我找不到这样做的有效方法。任何帮助表示赞赏。