sql calculate difference between previous dates code example
Example 1: find difference in dates sql
SELECT DATEDIFF(day, date1,date2) AS DateDiff
/*
DATEDIFF accepts three arguments
1- day, month, year etc what form you need difference
2,3- dates
*/
Example 2: sql get number of days between two dates
DATEDIFF(DAY, '1/1/2011', '3/1/2011')
Example 3: difference in dates sql
SELECT (END_DATE - START_DATE) Days-Total FROM MyTable
/*this works for oracle sql*/