I'm trying to import CSV data into MySQL database. I have four Date
fields. when the import finishes, all my dates are zeroes: .
I've set the date format to DATE
in Excel prior to saving it as CSV
. I've set the table field as DATE
in MySQL.
I'm using phpMyAdmin to do the import.
Mysql only excepts dates in
YYYY-MM-DD
format.The Date format in excel is 06/09/2015. Thus, not in the format that mysql is expecting. You must change this to a format that is accepted in mysql otherwise all your date fields will appear as
0000-00-00
.In order to change the date format in excel: right click on the top cell. Choose
format cells
from the drop down list. change thelocal
to something like'Afrikans'
. Choose the format that looks like2001-03-14
. Use the top cell tofill down
. Then save the document.Just a quick note: Excel sometimes tries to do too much and will revert this column back to a the
English(U.S)
default time zone. So, if you plan on doing more editing make sure that the column has not reverted back.Here is a link to more string literals on dev.mysql.