How do I subtract two dates that are in rows (not given in the query) Mysql -


say you're designing system library , want 2 dates subtracted - checkout date , checkin date. have file both of these dates along video id , customer id. want sort 7 or more days (the book due today or past due).

i had this, worked until date parts:

select customers.first_name, customers.last_name, video_checkout.checkout_date,  video_checkout.checkin_date video_rental, customers, video_checkout  video_checkout.checkout_date - video_checkout.checkin_date >= 7; 

so decided try date_sum , timestampdiff, after 2 hours of googling, doesn't seem date_sums or timestampdiffs support subtracting 2 dates tables.

is there anyway subtract dates in tables? can create query return subtracted dates, video id , customer id many entries?

using mysql workbench 6.3.4

the dates in video checkout file this:

delete video_checkout;  insert video_checkout values ( '1', '1', '2015-08-20', '2015-08-30' );  insert video_checkout values ( '1', '5', '2015-08-19', '2015-08-29' ); 

in end want this:

firstname | lastname | due date

something this

select customers.first_name, customers.last_name, video_checkout.checkout_date,  video_checkout.checkin_date video_rental, customers, video_checkout  datediff (video_checkout.checkout_date, video_checkout.checkin_date) >= 7; 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -