Hi all,
I have stored two dates in my mysql table. Starting date and ending date for the survey. Now from php, how can i extract if current_date is greater then end_date. The dates are being stored in datetime format in mysql.
Kindly guide me
Hi all,
I have stored two dates in my mysql table. Starting date and ending date for the survey. Now from php, how can i extract if current_date is greater then end_date. The dates are being stored in datetime format in mysql.
Kindly guide me
you should actually do this with mysql, not php
WHERE end_date < CURRENT_DATE
CURRENT_DATE is the standard sql function for the current date
it’s more efficient than passing in the current date from php, as in ‘2012-10-15’, because mysql would first have to parse that to make sure it’s actually a valid date
I agree; it would be better to do it in the DB. If you HAD to do it in PHP though, it’s pretty easy.
if ($row['end_date'] < date('Y-m-d H:i:s')) {
Even then though, a CASE statement to make a new column will still be a better option if he doesn’t want to limit his results to just those.