Mysql Request Date> = 90 days

I want to query the database for records where the date is equal to or greater than 90 days. This is what I still have:

$format = 'Ymj G:i:s'; $date = date ( $format ); // -90 days from today date ( $format, strtotime ( '-90 day' . $date ) ); 

I'm just a little sure how to structure a MYSQL query. It would be something like this (I know this is wrong, but I'm not sure what else to do):

 "SELECT * FROM recurringPayments WHERE lastpmt >= date ( $format, strtotime ( '-90 day' . $date ) ) "; 
+7
php mysql datetime
source share
2 answers
 <?php $d = date ( $format, strtotime ( '-90 days' ) ); mysql_query("SELECT * FROM recurringPayments WHERE lastpmt <= '$d'"); ?> 

Assuming you need data 90 days or older.

+5
source share
 <?php mysql_query("SELECT * FROM recurringPayments WHERE lastpmt <= (NOW() - INTERVAL 90 DAY)"); ?> 
+19
source share

All Articles