[thelist] MySQL Convert String To Date

Chris Marsh chris at ecleanuk.com
Wed Jul 23 07:45:17 CDT 2003


Rudy

> > The dates are in the format d[d]/m[m]/yyyy.
> > Can I convert such a string to a date that I can
> > perform calculations on within SQL using MySQL?
> 
> yes, but you have to unstring/restring it yourself first
> in order to get it into acceptable year-month-day format

[..]

> see, it works   ;o)

Sure does. Thanks.

> now, what did you say was holding you up from declaring a 
> proper datetime datatype?

I have inherited the database. Unfortunately because the date field is
of type varchar, there exist some incorrect dates, so I need to clean up
the data. Also, the dates that are pulled out of the database in string
format are then manipulated as such within the code of the application,
so although by the time I have finished the whole thing should be a lot
more efficient, it involves a deal of planning that I haven't got time
for at the moment. The short term aim is to simply add a small amount of
functionality to the search mechanism.

You will feel a slight shift in the Force when I have rectified the
datatype error.

Regards

Chris Marsh



More information about the thelist mailing list