input date

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yasaswi Pulavarti

    #1

    input date

    I have a date in mm/dd/yyyy format in a text file. I am using a perl
    script to update data into the tables. How can I upload the date in
    mm/dd/yyyy format into the MySQL native yyyy-mm-dd format without
    using any substring functions? Please help.
    Thanks,
    Yasaswi
  • Bill Karwin

    #2
    Re: input date

    Yasaswi Pulavarti wrote:
    [color=blue]
    > I have a date in mm/dd/yyyy format in a text file. I am using a perl
    > script to update data into the tables. How can I upload the date in
    > mm/dd/yyyy format into the MySQL native yyyy-mm-dd format without
    > using any substring functions? Please help.[/color]

    I use Date::Manip in my applications to parse and format dates. For
    instance, something like this might work for you:

    use Date::Manip;
    while(<>)
    {
    chomp;
    my $date = ParseDateString ($_);
    my $mysql_date = UnixDate($date, '%Y-%m-%d');
    print("INSERT INTO myTable (myDateField) VALUES($mysql_d ate);");
    }

    (NB: code not tested.)

    Regards,
    Bill K.

    Comment

    Working...