简体   繁体   English

Excel 默认日期时间格式 yyyy-mm-dd hh:mm:ss 与 yyyy-mm-dd hh:mm

[英]Excel default date time format yyyy-mm-dd hh:mm:ss versus yyyy-mm-dd hh:mm

I'm using Excel 2010 or Excel 2007 to import CSV file with date/time information.我正在使用 Excel 2010 或 Excel 2007 导入带有日期/时间信息的 CSV 文件。 The time stamp in my CSV file have the following format: yyyy-mm-dd hh:mm:ss.我的 CSV 文件中的时间戳具有以下格式:yyyy-mm-dd hh:mm:ss。 (ex: 2015-07-17 12:34:56) (例如:2015-07-17 12:34:56)

My problem is that Excel seems to auto-detect that the field is a date/time and it is removing the second.我的问题是 Excel 似乎自动检测到该字段是日期/时间,它正在删除第二个。 Therefore it shows my data as: "2015-07-17 12:34" without the second.因此它将我的数据显示为:“2015-07-17 12:34”,没有第二个。 Then, when I save my file again in CSV the second are discarded and not present in the CSV anymore !然后,当我再次以 CSV 格式保存我的文件时,第二个文件将被丢弃,不再出现在 CSV 文件中!

I find it very time consuming to change the custom cells format of all my files from "yyyy-mm-dd hh:mm" to "yyyy-mm-dd hh:mm:ss".我发现将所有文件的自定义单元格格式从“yyyy-mm-dd hh:mm”更改为“yyyy-mm-dd hh:mm:ss”非常耗时。

Is there a way to change the default date/time format in Excel setting or Windows registry?有没有办法更改 Excel 设置或 Windows 注册表中的默认日期/时间格式?

What is the best (correct) way to force Excel to keep the second when I open and save a CSV file with data/time information in it.当我打开并保存包含数据/时间信息的 CSV 文件时,强制 Excel 保留第二个的最佳(正确)方法是什么。

Thanks, ssinfod谢谢,ssinfod

in 'format Cells -> custom' write在“格式单元格 -> 自定义”中写入

yyyy-mm-dd h:mm:ss;@ 

in the Type box在类型框中

It is completely depend on your system date and time format:它完全取决于您的系统日期和时间格式:

  1. Go to Control Panel,进入控制面板,
  2. Click on "Region and Language",点击“区域和语言”,
  3. Click on "change date, time and number format"点击“更改日期、时间和数字格式”
  4. Set "short date", "long date", "short time" and "long time".设置“短日期”、“长日期”、“短时间”和“长时间”。

If you open a CSV file, the seconds are not dropped, they are hidden by the default:如果您打开一个CSV文件,秒数不会被删除,默认情况下它们是隐藏的:

在此处输入图片说明

If double-clicked will result in:如果双击会导致:

在此处输入图片说明

If you then save the Excel as CSV , the seconds will be dropped.如果然后将 Excel 保存为CSV ,则秒数被删除。 To save these seconds, you must reformat the cells as:要保存这些秒数,您必须将单元格重新格式化为:

yyyy-mm-dd hh:mm:ss yyyy-mm-dd hh:mm:ss

before doing the SaveAs在执行SaveAs之前

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

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