By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,058 Members | 1,217 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,058 IT Pros & Developers. It's quick & easy.

input date

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Yasaswi Pulavarti wrote:
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.


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_date);");
}

(NB: code not tested.)

Regards,
Bill K.
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.