简体   繁体   English

如何从日期值获取日月年中的日期

[英]How to get the date in day month year from date value

I am using excel uploading operation having date data. 我正在使用具有日期数据的Excel上传操作。 When I upload excel with date 17-Oct-2012 and I am getting 41199. 当我上传日期为2012年10月17日的excel时,我得到41199。

You need to convert the date format from OLE Automation to the .net format by using DateTime.FromOADate. 您需要通过使用DateTime.FromOADate将日期格式从OLE自动化转换为.net格式。

double doubleValue = double.Parse(b);
DateTime convertedDate = DateTime.FromOADate(doubleValue );
public static DateTime FromExcelSerialDate(int serialDate){return new DateTime(1899, 12, 31).AddDays(serialDate);}

Or other ways from old issues; 或其他解决旧问题的方法;

How do I convert an Excel serial date number to a .NET DateTime? 如何将Excel序列号转换为.NET DateTime?

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

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