Skip to content
Advertisement

Select data that wont expire in the next 60 days

I’m trying to select data that won’t expire in the next 60 days so far I have this

 $sql = "SELECT id FROM cooler WHERE expiry_date > CURDATE()";

which only shows data that has not expire.

Advertisement

Answer

Simply add 60 days to the CURDATE() with DATE_ADD and an INTERVAL of +60 DAY:

$sql = "SELECT id FROM cooler WHERE expiry_date > DATE_ADD(CURDATE(), INTERVAL +60 DAY)";
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement