Home > DeveloperSection > Forums > MySQL reading date from CSV
Madam Walker
Madam Walker

Total Post:22

Posted on    July-09-2013 3:03 AM


 1 Reply(s)
 950  View(s)
Rate this:
Hi Expert,

Right now I have a database in the format with columns:

id - purchase_date - integer fields.....
And an import of a CSV using the script

LOAD DATA LOCAL INFILE 'C:/Users/Alex/Desktop/work/natgas2.csv' INTO TABLE pricemodel.natural_gas 
        TERMINATED BY ',' 
        ENCLOSED BY '"'
        LINES TERMINATED BY '\r\n';
And everything's being imported correctly except for the dates which are in the format right now of:

So the question is what format do they have to be in for them to be read correctly into my database?

Please help?

Thanks in advance. 


Total Post:604

Posted on    July-09-2013 4:36 AM

Hi Madam!

Try as following line of code

YYYY-MM-DD HH:MM:SS (24-hour time)

If the field is of type timestamp.

For example:

2011-01-03 00:00:00

I hope it resolve your problem. 

Don't want to miss updates? Please click the below button!

Follow MindStick