Connecting Tech Pros Worldwide Forums | Help | Site Map

Date format

Donald Campbell
Guest
 
Posts: n/a
#1: Aug 18 '08

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
Guest
 
Posts: n/a
#2: Aug 18 '08

re: Date format


>I am looking at moving some old database systems to MySQL and I am
Quote:
>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.
Quote:
>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
Guest
 
Posts: n/a
#3: Aug 18 '08

re: Date format


In article <SI$AnlAoddqIFAJo@suedonltd.demon.co.uk>,
Donald Campbell <suedon@suedon.co.ukwrote:
Quote:
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.
Closed Thread