Here is example difference between two dates in days (first parameter), but you can use for example hour or month, etc.
select salesid, linenum, itemid, qtyordered, createddatetime, confirmeddlv,
datediff( day, createddatetime, confirmeddlv ) as diffdays
from salesline
where
confirmeddlv > '2017/12/01' and
datediff( day, createddatetime, confirmeddlv ) <= 7
Output:
salesid createddatetime confirmeddlv diffdays
-------------------- ----------------------- ----------------------- -----------
PO171475 2017-12-08 10:51:45.000 2017-12-10 00:00:00.000 2
PO171475 2017-12-08 10:52:03.000 2017-12-10 00:00:00.000 2
PO171675 2017-11-27 19:58:26.000 2017-12-04 00:00:00.000 7
...
No comments:
Post a Comment