简体   繁体   English

excel 日期格式不起作用 mm/dd/yyyy 到 yyyy-mm-dd

[英]excel date format not working mm/dd/yyyy to yyyy-mm-dd

Have a column defined as Date yyyy-mm-dd: Date format setting The 2020-04-13 date is the existing data.有一列定义为日期 yyyy-mm-dd:日期格式设置2020-04-13 日期是现有数据。 I pasted in new data 03/31/2020.我粘贴了 2020 年 3 月 31 日的新数据。
I tried doing format painter to apply the cell with 2020-04-13 to 03/13/2020, but the format would not change.我尝试使用格式刷将 2020-04-13 的单元格应用到 2020 年 3 月 13 日,但格式不会改变。 Also checked the Date format dialogue as show above, both cells show the same setting.还检查了上面显示的日期格式对话框,两个单元格显示相同的设置。 Why is the 03/31/2020 not changing to the desired yyyy-mm-dd format?为什么 03/31/2020 没有更改为所需的 yyyy-mm-dd 格式?

BTW, In my windows date format settings, I have: Windows date format setting顺便说一句,在我的 windows 日期格式设置中,我有: Windows 日期格式设置在此处输入图像描述

@Scott Cramer answered your question but didn't provide a solution. @Scott Cramer 回答了您的问题,但没有提供解决方案。 That lies in how you enter the date[s] you want to format.这取决于您如何输入要格式化的日期。

If you enter a date in a cell that is formatted as Date Excel will record a "True date" which is a number that is converted to look like a date by the cell format.如果您在格式为Date Excel 将记录一个“真实日期”,这是一个数字,通过单元格格式转换为看起来像日期。 If Excel doesn't recognize your entry as a date, even if you do, the entered value will be recorded as a text string, just what you entered, and I'll call it a "fake date".如果 Excel 没有将您输入的内容识别为日期,即使您识别了,输入的值也会被记录为文本字符串,就像您输入的内容一样,我将其称为“假日期”。 You can see that it doesn't really matter what you enter or what format you set, only what Excel understands.你可以看到,你输入什么或设置什么格式并不重要,只有 Excel 能理解什么。

Excel understands what you have set up in Windows settings. Excel 了解您在 Windows 设置中所做的设置。 Now, you see that your settings are confusing.现在,您看到您的设置令人困惑。 The long date is set up as Month, Day, Year whereas the Short date gas it Year, Month, Day.长日期设置为月、日、年,而短日期设置为年、月、日。 I haven't tried whether this will be an issue of significance because it's unlikely that you will enter a Long date in a cell and ask Excel to recognize it as a true date.我没有尝试过这是否会是一个重要问题,因为您不太可能在单元格中输入长日期并要求 Excel 将其识别为真实日期。 Most of the time Short dates will be entered.大多数情况下将输入短日期。 Based on your settings you should enter "2020-3-13".根据您的设置,您应该输入“2020-3-13”。 If you want "31-3-2020" to be recognized as a date when you enter it in a cell you must change the setting to the Month, Day, Year sequence.如果您希望在单元格中输入“31-3-2020”时将其识别为日期,则必须将设置更改为月、日、年序列。

Two notes in this regard.在这方面有两个注意事项。

  1. In most cases you don't need to enter all four digits of the year.在大多数情况下,您不需要输入所有四位数的年份。 Excel will interpret the last two correctly. Excel 将正确解释最后两个。
  2. The date separators are important.日期分隔符很重要。 If your set format has dashes Excel won't understand slashes and vv如果您的设置格式有破折号 Excel 将无法理解斜杠和 vv

And, finally, you can change the format of a cell containing a date to General or Number and see the number underlying a true date.最后,您可以将包含日期的单元格的格式更改为“ General或“ Number ”,然后查看真实日期背后的数字。 You can also try a calculation.您也可以尝试计算。 If A1 contains a true date then =A1+1 will return a date of the next day.如果 A1 包含真实日期,则 =A1+1 将返回第二天的日期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM