I need some help with MySQL syntax... I would know how to write it in PHP but I am not sure how to write it for MySQL.
I have a SQL table 'webcal_entry' and a column in it called 'cal_date' which contains dates in the numeric format yyyymmdd
I am trying to write a query that only takes events that are no older than 1 month.
Let's assume that:
$date = webcal_entry_user.cal_login
if it were PHP I would write this:
$year = (int) substr($date,0,-4);
$month = (int) substr($date,-4,2);
if ( $year == date('Y') && $month > ( date('n') - 1 ) )
however I have no idea how to write this in my SQL query:
$sql .= "WHERE webcal_entry.cal_id = webcal_entry_user.cal_id AND " .
"webcal_entry_user.cal_login = '" . $user . "' AND " .
"webcal_entry.cal_date = '" . ??? . "'";
I would appreciate your help.
Thank you