I have data similar to the following:
`date1` `date2`
2013-04-02 NULL
2013-03-26 NULL
2013-03-26 2013-03-06
2013-03-25 2013-03-05
I would like to find the difference in days. For example:
`date1` `date2` `difference`
2013-04-02 NULL NULL
2013-03-26 NULL NULL
2013-03-26 2013-03-27 1.0 # DAYS
2013-03-25 2013-03-28 3.0
How would I calculate this difference?
You can use a DATEDIFF function.
DATEDIFF(date1,date2)
The following SELECT statement:
SELECT DATEDIFF('2014-11-30','2014-11-29') AS DiffDate
Output will be.
DiffDate
1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.