how to keep the datetime format from csv to mysql database when importing data?
I have a csv file where I changed th开发者_高级运维e initial datetime format:
- from
m/d/yyyy h:mm (6/15/2011 5:26:00 PM)
- to
yyyy-dd-mm h:mm (2011-15-06 17:26)
This was done in order to avoid 0000-00-00
as datetime value in MySQL database when importing data from that csv to MySQL.
This did not fix the problem. I still found 0000-00-00
as datetime value in my database.
To fix the problem, I first created the database in mysql (before importing the data from the csv file), and I used Datetime type in order to keep the values of date and time from that csv file.
Did I forget something? or is there any better way to fix that problem?
You might be having this problem because you aren't putting your dates in quotes. This won't work
INSERT INTO some_table 2011-07-12;
but this will
INSERT INTO some_table "2011-07-12";
Try editing one of the rows in your CSV file to put the date in quotes and see if that one gets read in properly.
try change day/month 2011-15-06---->2011-06-15
;)
and look at zeros may be it 00-00-0000
not 0000-00-00
This should solve this issue.
精彩评论