I stored with dates in this format 6th July,2012 in my table. I want to loop through them and send an email to the admin if the date is today’s date.
i tried this but think i need to concert the date format first.
SELECT email, name, phone_no FROM table WHERE TO_DAYS(date)=To_DAYS(NOW());
If true then send email to admin.
//eg. John's birthday is today. Pls call him on 00001332424;
Thanks
Yes, you should convert to native mysql date/time formats first. Storing as a date as a string is all fine and dandy if you never have to manipulate that date. But as soon as you do, then you’re in for a world of pain – can’t uses indexes, have to convert every string EVERY TIME you run a query, etc…
Once you’ve converted that string to a native date field, then it’s a simple matter of
To give you an idea what’s possible once you’ve got your dates in ‘native’ format, here’s the mysql date/time manipulation functions: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
there’s lots of them, but almost all only work on native date fields, not on arbitrary strings (except the ones that convert string<->native).