采购订单超期查询
小于 1 分钟
代码示例
SELECT T0.[DocNum], T0.[CardName], T0.[DocDate], T1.[ItemCode], T1.[Dscription]
, T1.[Quantity], T0.[TaxDate]
, datediff(d, T0.[TaxDate], GetDate()) AS '超期日期'
, CASE
WHEN datediff(d, T0.[TaxDate], GetDate()) > 0 THEN '超' + ' ' + CAST(datediff(d, T0.[TaxDate], GetDate()) AS nvarchar) + '天'
WHEN datediff(d, T0.[TaxDate], GetDate()) < 0 THEN '剩' + ' ' + CAST(datediff(d, GetDate(), T0.[TaxDate]) AS nvarchar) + '天'
END AS '超期'
FROM OPOR T0
INNER JOIN POR1 T1 ON T0.[DocEntry] = T1.[DocEntry]
WHERE datediff(d, T0.[TaxDate], GetDate()) > 0
ORDER BY T0.[DocNum] DESC