I have a column with dates formated as dd/mm/yyyy when I export a CSV file the date is yyyy/mm/dd
How can I maintain the correct date format in the exported file?
Thank you.
Related
I've been producing a csv file from Salesforce Marketing Cloud. The date column is using two different date formats for seemingly random dates:
How can I stop it from doing this? I have also exported it from SFMC in a text format, and all the dates are in the same format in that file, but as soon as I convert it to CSV it puts them in this variety of formats. Can anyone help?
Excel tries to fix it for you. You should import into excel using the' Data Tab > Get External Data'. As you import make sure you select the correct date format for the column with your dates. ie MM/DD/YYYY h:mm:ss AM/PM.
I have a table in excel (CSV) which I am importing into phpmyadmin.
the cells show the date fine such as: 09/11/2012 0:00
The cell format is "custom"
when I import the table into phpmyadmin, all the dates turn to: 0000-00-00 00:00:00
What is the correct way to put them in excel so that I can import them into the database.
And how can I convert them to the correct format?
Format your excel dates into the format php accepts. E.g. yyyy-mm-dd h:mm:ss
In excel use the following steps:
Right click the column heading that contains the dates.
Select Format Cells
Click the "Custom" category
Paste "yyyy-mm-dd h:mm:ss" in the input box.
*. Save the document.
In php SQL query, make sure to set this column to date in anycase if php side is going to treat the date as a string.
You may use : ‘STR_TO_DATE(#date, '%Y-%c-%e %H:%i:%S')‘
I had this problem and thought I formatted them to format YYYY-MM-DD. They were displayed that way, but in the Formula bar it was still in DD/MM/YYYY format.
So I actively changed the date with:
=YEAR(A1)&"-"&IF(MONTH(A1)<10;"0";"")&MONTH(A1)&"-"&IF(DAY(A1)<10;"0";"")&DAY(A1)
And then copied the values of these cells to replace the original ones...
I have a MS Excel file in which a column contains date in the format m/d/yyyy and mm/dd/yyyy. I wanted all these dates to be imported in to a MySQL table.
So in MS Excel, I changed the cell format to custom date 'yyyy-mm-dd' and everything looked fine in the excel columns. When I exported it as .csv, all dates were in the original format i.e., m/d/yyyy and mm/dd/yyyy but not as 'yyyy-mm-dd'.
Please help me in this regard. Thank you!
Like David mentioned, you may have to replace the text before importing it to the MySQL table. You can try this formula:
=TEXT(A2,"yyyy-mm-dd")
And copy down. Then do a copy->Paste Values into the original date column. Then delete the temporary column with the Text() formula.
Try importing it after you replace the text. It should work out.
I have a table in excel (CSV) which I am importing into phpmyadmin.
the cells show the date fine such as: 09/11/2012 0:00
The cell format is "custom"
when I import the table into phpmyadmin, all the dates turn to: 0000-00-00 00:00:00
What is the correct way to put them in excel so that I can import them into the database.
And how can I convert them to the correct format?
Format your excel dates into the format php accepts. E.g. yyyy-mm-dd h:mm:ss
In excel use the following steps:
Right click the column heading that contains the dates.
Select Format Cells
Click the "Custom" category
Paste "yyyy-mm-dd h:mm:ss" in the input box.
*. Save the document.
In php SQL query, make sure to set this column to date in anycase if php side is going to treat the date as a string.
You may use : ‘STR_TO_DATE(#date, '%Y-%c-%e %H:%i:%S')‘
I had this problem and thought I formatted them to format YYYY-MM-DD. They were displayed that way, but in the Formula bar it was still in DD/MM/YYYY format.
So I actively changed the date with:
=YEAR(A1)&"-"&IF(MONTH(A1)<10;"0";"")&MONTH(A1)&"-"&IF(DAY(A1)<10;"0";"")&DAY(A1)
And then copied the values of these cells to replace the original ones...
My excel sheet has the following format : dd/mm/YYYY
ex: 24/10/2010 (european format)
and my mysql needs: YYYY-mm-dd (US format)
How can I format the date in Excel to have this US format ?
I tried with cell format, but I don't have the desired format
Regards
Here's how you can find this Number format in Excel:
Go to Format Cells and then the Number tab.
Select Date
Change the Locale to English (U.K.)
The fifth item on the list (on my U.S. version of Excel) is the format you're looking for.
Hope that helps!
For the hours, minutes and second
go in the custom category and enter this :
yyyy-mm-dd hh:mm:ss
Use the text function -- assuming that the date to be converted was in cell A1, =TEXT(A1,"YYYYMMDD") will get your data into a format that mysql will understand as a date.
There are many solutions, but I reformat the dates for mysql using this formula (assuming your date is in cell E2):
=YEAR(E2)&"-"&RIGHT(TRIM(100+MONTH(E2)),2)&"-"&RIGHT(TRIM(100+DAY(E2)),2)