且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何解决日期格式excel单元格值

更新时间:2023-11-29 13:24:46

嗨Levimatt,

请注意,ECMA-376中的日期存储为数字值(序列日期)。


Hi Levimatt,

Please be aware that dates in ECMA-376 are stored as numeric values (serial dates).

DateTime oaDate = new DateTime(2009, 12, 11);
double oaValue = oaDate.ToOADate();
Console.WriteLine("Serial value of date 2009-12-11: " + oaValue);
            
DateTime newDate = DateTime.FromOADate(oaValue);
Console.WriteLine("DateTime of serial date value (40158): " + oaDate);

Console.Read();



以上结果在控制台中显示:




The above results in this in the console:


Serial value of date 2009-12-11: 40158
DateTime of serial date value (40158): 11-12-2009 00:00:00





在.Net-terms 您所体验的东西被称为"OADate"(OLE自动化日期)

我希望这会有所帮助,

:o)




In .Net-terms what you experience is called an "OADate" (OLE Automation Date)

I hope this helps,

:o)