views:

42

answers:

2

Hi guys,

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

$format = 'Y-m-j G:i:s'; 

$date = date ( $format ); 

// -90 days from today 

date ( $format, strtotime ( '-90 day' . $date ) ); 

I'm just a bit unsure now how to structure the MYSQL query. Would it be something like this (I know this is wrong but i'm unsure as to what else to do):

"SELECT * FROM recurringPayments WHERE lastpmt >= date ( $format, strtotime ( '-90 day' . $date ) ) ";
+2  A: 
<?php
$d = date ( $format, strtotime ( '-90 days' ) );

mysql_query("SELECT * FROM recurringPayments WHERE lastpmt <= '$d'");
?>

Assuming you want data 90 days and older.

methodin
+1  A: 
<?php
mysql_query("SELECT * FROM recurringPayments WHERE lastpmt <= (NOW() - INTERVAL 90 DAY)");
?>
ITroubs