user4707168
user4707168

Reputation:

Get Yesterday's date in mysql with different time

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

Answers (2)

Noman
Noman

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

Abhik Chakraborty
Abhik Chakraborty

Reputation: 44874

You need to convert the datetime value to date using date function as

AND date(ba.checkout_date)

Upvotes: 1

Related Questions