Discussion:
Date format
(too old to reply)
Donald Campbell
2008-08-18 20:11:20 UTC
Permalink
I am looking at moving some old database systems to MySQL and I am
currently working on data loading using mysqlinport.

I have an issue with dates as all the data that is coming my way has
dates in DD/MM/YYYY. the load routines look to only accept it in
YYYY/MM/DD.

Is there anyway of telling the routines to use the European date format?

Would be nice if it could display dates in the format as well.

I did find a variable called "data_format" in the online documentation,
however, it said that it was no-longer used.

THanks.

Don
Gordon Burditt
2008-08-18 21:45:52 UTC
Permalink
Post by Donald Campbell
I am looking at moving some old database systems to MySQL and I am
currently working on data loading using mysqlinport.
I have an issue with dates as all the data that is coming my way has
dates in DD/MM/YYYY. the load routines look to only accept it in
YYYY/MM/DD.
My suggestion is not to try to fight MySQL in terms of how the data
is *stored*. Using date_format(), you can get the data out of the
database in one of an incredible number of formats. Using str_to_date(),
you can convert input in lots of formats to a date, provided you know
what format is coming in.
Post by Donald Campbell
Is there anyway of telling the routines to use the European date format?
I'm not that experienced in the use of mysqlimport, but I believe you
can import the files like this:

1. Set up your table, with string fields for the dates.
2. Do the import.
3. Add date fields to the table.
4. Fill the date fields from the corresponding string fields, using
something like
UPDATE table SET datefieldname = str_to_date(stringfieldname, '%d/%m/%Y');
Repeat if you've got more than one date field you're trying to import.
5. Drop the string fields.
Tim Streater
2008-08-18 21:52:43 UTC
Permalink
Post by Donald Campbell
I am looking at moving some old database systems to MySQL and I am
currently working on data loading using mysqlinport.
I have an issue with dates as all the data that is coming my way has
dates in DD/MM/YYYY. the load routines look to only accept it in
YYYY/MM/DD.
Is there anyway of telling the routines to use the European date format?
Would be nice if it could display dates in the format as well.
No, you have to write some PHP or JavaScript (or both, as I did) to
reformat it to/from internal format from/to human format. While you're
at it make it flexible, so it allows any delimiter rather than just the
slash, allows month names as well as month numbers, and makes some sort
of guess about what 2-digit years mean.

Continue reading on narkive:
Loading...