I have two columns: rental_date
and actual_retdate
. I need to find the amount of days between the actual_retdate
and rental_date
. The actual_retdate
can be null for some instances so I would like to find the amount of days between today's date and the rental date in those situations.
Currently I have:
select rental_date, actual_retdate, actual_retdate - rental_date as 'Daysbetween'
from rental_agreement
This gives me answers of:
Rental_date actual_retdate Daysbetween 2014-07-04 2014-07-11 7 2016-05-06 2016-05-08 2 2016-08-07 2016-09-07 100 2015-02-02 2015-02-10 8 2015-10-10 2015-10-15 5 2015-08-07 2015-08-17 10 2017-02-04 NULL NULL 2016-07-08 2016-07-16 8 2017-03-02 NULL NULL 2015-03-15 2015-04-15 100
100
. In MySQL, we can get a difference in days usingTIMESTAMPDIFF(DAY,dateexpr1,dateexpr2)
. – spencer7593