I have a row from an SQL table, and one field is a DATE. (The value may be undefined, as DATE has no default value). How can I tell if this date, if it exists, is still in the future?
I searched for answers and found lots of ways to extract all records that pass this test, but I don’t want to do that. I just want to check this one previously extracted record. Sorry for the newbie question!
$userQuery = "SELECT * FROM `passwords` WHERE `name` = '$name' LIMIT 1";
$userResult = mysql_query($userQuery);
$userRow = mysql_fetch_assoc($userResult);
$bestBeforeDate = $userRow['bestBeforeDate']; // field is in DATE format
// what now? How to find if the 'best Before Date' has passed?
You can do it in SQL as additional column
EDIT
You can do this in one query while reading other values from your table.
Example (not knowing the column names of your table)
Example output: