MySQL mysql的excel格式日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4817212/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
excel format date for mysql
提问by yarek
My excel sheet has the following format : dd/mm/YYYY
我的 Excel 表格格式如下:dd/mm/YYYY
ex: 24/10/2010 (european format)
例如:24/10/2010(欧洲格式)
and my mysql needs: YYYY-mm-dd(US format)
而我的 mysql 需要:YYYY-mm-dd(美国格式)
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
如何在 Excel 中格式化日期以具有这种美国格式?我尝试使用单元格格式,但我没有想要的格式
Regards
问候
回答by Scott Cranfill
Here's how you can find this Number format in Excel:
以下是在 Excel 中查找此数字格式的方法:
- Go to Format Cellsand then the Numbertab.
- 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.
- 转到设置单元格格式,然后转到数字选项卡。
- 选择日期
- 将区域设置更改为英语(英国)
- 列表中的第五项(在我的美国版 Excel 中)是您要查找的格式。
Hope that helps!
希望有帮助!
回答by jpprade
Four the hours, minutes and second
四时分秒
go in the custom category and enter this :
进入自定义类别并输入:
yyyy-mm-dd hh:mm:ss
yyyy-mm-dd hh:mm:ss
回答by Andrew
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.
使用 text 函数——假设要转换的日期在单元格 A1 中,=TEXT(A1,"YYYYMMDD") 会将您的数据转换为 mysql 可以理解为日期的格式。
回答by mgalka
There are many solutions, but I reformat the dates for mysql using this formula (assuming your date is in cell E2):
有很多解决方案,但我使用此公式重新格式化 mysql 的日期(假设您的日期在单元格 E2 中):
=YEAR(E2)&"-"&RIGHT(TRIM(100+MONTH(E2)),2)&"-"&RIGHT(TRIM(100+DAY(E2)),2)