跳至主要內容

销售订单正负10天内到期查询

五六零网校小于 1 分钟

示例代码

SELECT CASE 
		WHEN datediff(d, T0.[DocDueDate], GetDate()) > 0 THEN '超' + ' ' + CAST(datediff(d, T0.[DocDueDate], GetDate()) AS nvarchar) + '天'
		WHEN datediff(d, T0.[DocDueDate], GetDate()) < 0 THEN '剩' + ' ' + CAST(datediff(d, GetDate(), T0.[DocDueDate]) AS nvarchar) + '天'
	END AS '超期' ,T0.[DocNum], T0.[CardName], T0.[DocDate], T1.[ItemCode], T1.[Dscription]
	, T1.[Quantity], T0.[TaxDate]
	
FROM ORDR T0
	INNER JOIN RDR1 T1 ON T0.[DocEntry] = T1.[DocEntry]
WHERE datediff(d, T0.[DocDueDate], GetDate()) >-10 AND   datediff(d, T0.[DocDueDate], GetDate()) <10
ORDER BY T0.[DocNum] DESC