销售订单交期查询
小于 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 T0.[DocDate]>=[%0] and T0.[DocDate]<=[%1]
ORDER BY T0.[DocNum] DESC