Donjwan
Donjwan

Reputation: 35

MySql > select record only form yesterday

I want to select all record form yesterday

I use the following

date > CURDATE() - INTERVAL 1

but this select today records as will

I just want to select yesterdays records

any ideas ?

Upvotes: 0

Views: 267

Answers (1)

1000111
1000111

Reputation: 13519

Your condition is wrong. It should be the following:

date >= CURDATE() - INTERVAL 1 DAY AND date < CURDATE()

CURDATE() - INTERVAL 1 DAY -> date of yesterday.

In order to select records of yesterday only you can use the condition given above or the condition given below:

date = CURDATE() - INTERVAL 1 DAY

Upvotes: 1

Related Questions