Donjwan Donjwan - 2 months ago 6
MySQL Question

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 ?

Answer

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
Comments