Antonio De Luna wrote:
> 
> Hi, I've got a csv archive with a date field 15/02/03, how can I load it to a
> date field with the mysql date format (ISO ? )  2003-02-15 ?

Well, if you're a Unix type, then you could pipe the input through a
small Perl script:

#!/usr/bin/perl -w
while (<>)
{
        s/(\d\d)\/(\d\d)\/(\d\d)/20$3-$2-$1/g;
        print $_;
}

Note that this assumes the years are all in the 2000's. If you want to
distinguish then you need to know the cutoff for the 1900's and add some
conditionals to the script.

Then if the script is called something like convert_date_format.pl, you
could use:

cat input.csv | convert_date_format.pl | whatever

... "whatever" being either another filter or mysql (if it's now in the
right format) or some output file.

Probably the Perl buffs in the audience can hack together an even
shorter one-liner that takes into account the Y2K possibilities...

HTH

-Neil

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to