Reputation:
I have problem i want to fetch yesterday's date data from mysql table.Which i try below query.
select id FROM booking_assigned ba WHERE ba.is_checkout = '1' AND ba.checkout_date = CURDATE() - INTERVAL 1 DAY
But in checkout_date columun value is as 2015-04-14 16:26:08.So, that's why above query return zero result
Actually I want result from this query.
I didn't get any result,And also every time checkout_date time is different.
Upvotes: 0
Views: 103
Reputation: 4116
convert checkout_date from DATETIME to DATE.
select id FROM booking_assigned ba WHERE ba.is_checkout = '1' AND DATE(ba.checkout_date) = CURDATE() - INTERVAL 1 DAY
Upvotes: 0
Reputation: 44874
You need to convert the datetime value to date using date
function as
AND date(ba.checkout_date)
Upvotes: 1