|
Posted by rcamarda on 12/21/05 23:47
DATEDIFF ( datepart , startdate , enddate ) is the function that will
return the interval between two dates.
Check the help in QA for the datepart arguments.
As far to tell the difference between two rows: this isnt perfect.
I wrote this using the NORTHWIND database, but it I think it is exacly
what you are looking for:
SELECT
ORDERID,
ORDERDATE,
DATEDIFF(d,orderdate, (SELECT TOP 1 ORDERDATE FROM ORDERS WHERE
ORDERID > O.ORDERID ORDER BY ORDERID )) AS DAYS
FROM ORDERS O
Navigation:
[Reply to this message]
|