Hi there!
I guess this is a simple one:
I want to select all rows where a date-field is "older" than X days?
I used this before:
"SELECT * FROM table WHERE (registerDate = (CURDATE() - INTERVAL 31 DAY))"
The problem is, that I want to select ALL entries which are "older" than 31 days...
Any ideas??? Thx in advance!
Dear friend,
try this query
"select * from tablename WHERE TO_DAYS(CURRENT_DATE) - TO_DAYS(datefield) <= 31"
regards sureshbabubv
...the answer was sooo easy...shame on me...here we go:
$lastMonth= mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); $myDate = date ( "Y-m-d", $lastMonth);
$query = "SELECT * FROM table WHERE (dateField < '$myDate )";
:eek: :eek: :eek: