Home > front end >  How to insert date( in different format ) coming from a CSV file to MySQL
How to insert date( in different format ) coming from a CSV file to MySQL

Time:04-18

I'm inserting a row coming from a CSV file into my SQL database. The birthdate column that I have on the CSV file has a date format like this 10/29/1992, it seems that the Google Sheets that I use to create the CSV file convert it to that format even though I input it like this 1992-10-29, since the latter format is the format in the SQL database for dates.

So I tried importing the CSV file to my table in the database, and it won't insert the birthdate column correctly, it inserts 0000-00-00 and gives me a warning Mysql date warning data truncated. So it seems it's impossible to insert in this format 10/29/1992

What could be the best way to solve this? Without handling this on the backend or server side? Can this be handled in the phpMyAdmin settings or in google sheets so that it won't convert the date I input to a different format?

CodePudding user response:

I just found out that in Google Sheets where I create the CSV file, there's a setting where you can custom format your dates for a date column. I guess that's all I needed so that the date format from the CSV to the MySQL table will match. The setting can be found in Format-> Numbers-> Custom date and time

  • Related