I need to check that a UK date, stored as string in the format dd/mm/yyyy in a database table (postmeta.event_date), is between two dates using SLQ format BETWEEN 'yyyy-mm-dd' AND 'yyyy-mm-dd+28'. I’m ok with working out the dates to check between, it’s the date to check that I’m having issues with because it is in the wrong format for SQL.
I have no way of changing the format of the date to check, as it is attached to a post, and I don’t know what posts to get out of the database until I can check if they are between my chosen dates…
Any ideas if this is possible, or am I looking at two queries (grab all the posts get the IDs of the ones that I actually want by checking the data in PHP)? Thanks.
The way to convert your date would be to use
str_to_date:This converts your date to something you can use in your
BETWEENformula.http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_str-to-date