OK, I have put into my mySQL database a date (the date only) as a varchar of 2. So, if, say today was May 18, 2011, I store the 18 in the varchar storedDate. Now I want to retrieve that and compare it with today. Isn’t working for me.
I am storing these broken out for a particular reason as I wanted to store the complete date (month day year) but other requirements is not allowing for that - might have been easier.
Here is one way I compare it after my getting the row from the master query
// this works
if ($info['storedMonth'] == date("F"))
echo 'Months match<br>';
else
echo 'oops, months not matching???<br>?';
// this does not
if (trim($info['storedDate']) == strtotime(date("j")))
echo 'Dates match<br>';
else
echo 'hmmmmm. dates not matching!!!<br>';
I also tried by removing the strtotime, trim and both. Not working.
Glad it’s working, but I’d still recommend using a proper date column. More flexible for other things you may wish to do in future (e.g. sorting, selecting) and would use less space too.