Date format

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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

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.



Re: Date format

Quoted text here. Click to load it

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.

Quoted text here. Click to load it

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.

Re: Date format

Quoted text here. Click to load it

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.

Site Timeline