in reply to date formatting again

baperl:

All databases that I've worked with have date parsing functions available in them already. So read your database documentation on how to format and parse dates, and let the database do the work.

Secondly: You are storing the dates as dates and not strings, right? If you're using strings you may be making things harder for yourself down the road.

Update: A little googling turned up: http://forums.mysql.com/read.php?10,136269,136273#msg-136273, http://stackoverflow.com/questions/2238611/how-to-change-string-date-to-mysql-date-format-at-time-of-import-of-csv-using-my. Does google not work over there?

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: date formatting again
by baperl (Sexton) on Jan 23, 2012 at 16:36 UTC
    I am storing the dates as dates. I did look up the links, thanks for those, @roboticus however, when I run the code by adding @var into my LOAD statement,
    LOAD DATA LOCAL INFILE '$fname' INTO TABLE $tname FIELDS TERMINATED BY + ',' LINES TERMINATED BY '\r\n' (trade_date,....,@var) SET trade_date + = str_to_date(@var, '%d/%m/%Y');
    I get the following error:
    Global symbol "@var" requires explicit package name at process.pl line + 37. Execution of process.pl aborted due to compilation errors.