Problems with dates in MySQL statement
Posted: Mon Apr 28, 2003 12:19 pm
I'm trying to get a recordset of all records with a release date newer than 60 days. I first create a date variable of 60 days ago. Then use it in my MySQL query statement shown below. However, when I display the results, I get ALL the records, regardless of date. My dates are stored in DATE formatted data in MySQL.
$TwoMonthsAgo = date("Y-m-d", mktime(0,0,0, date(m), date(d)-60,date(Y)));
SELECT *
FROM music
WHERE ReleaseDate > $TwoMonthsAgo
I've been reading up on much of the date functions in PHP, but I'm not sure what the best way to go about this is. Am I at least on the right track?
$TwoMonthsAgo = date("Y-m-d", mktime(0,0,0, date(m), date(d)-60,date(Y)));
SELECT *
FROM music
WHERE ReleaseDate > $TwoMonthsAgo
I've been reading up on much of the date functions in PHP, but I'm not sure what the best way to go about this is. Am I at least on the right track?