AndyB Posted January 23, 2008 Share Posted January 23, 2008 I managed to force ISO standard date formats for user entries in a database, but forgot that the client can also enter dates. Unsurprisingly, the Australian client has entered dates (in a different field) in the Oz-style dd/mm/yyyy. I need a query that effectively chooses records where Oz-style date is between two ISO-style dates: SELECT ... WHERE iso_date1>Oz_date and iso_date2<Oz_date ORDER by Oz_date Nothing is jumping out of the ref manual that seems to apply. I'm sure it's blindingly obvious, but not to me. Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted January 23, 2008 Share Posted January 23, 2008 Would it be possible to use something like DATE_FORMAT(Oz_date, '%Y-%m-%d') AS oz2iso_date and then compare the ISO dates to that? Quote Link to comment Share on other sites More sharing options...
Barand Posted January 23, 2008 Share Posted January 23, 2008 try WHERE STR_TO_DATE(oz_date, '%d/%m/%Y') BETWEEN '$iso1' AND '$iso2' ... Quote Link to comment Share on other sites More sharing options...
AndyB Posted January 24, 2008 Author Share Posted January 24, 2008 Thanks, Barry. After the query failed miserably during localhost testing, I decided to move it to the client's server and it worked. The production server control panel declines to reveal what MySQL release is running. Quote Link to comment Share on other sites More sharing options...
Barand Posted January 24, 2008 Share Posted January 24, 2008 Have you tried VERSION() Returns a string that indicates the MySQL server version. mysql> SELECT VERSION(); -> '3.23.13-log' Note that if your version string ends with -log this means that logging is enabled. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.