using excel dates for importing into phpmyadmin sql

前端 未结 2 643
名媛妹妹
名媛妹妹 2020-12-20 00:35

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

相关标签:
2条回答
  • 2020-12-20 01:10

    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')‘

    0 讨论(0)
  • 2020-12-20 01:28

    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...

    0 讨论(0)
提交回复
热议问题