其中39938是自1900年1月1日以来的天数?
In that case, use the framework library function 100 .
此函数encapsulates包含所有细节,并进行边界判断.
鉴于其历史价值,以下是一种可能的实现:
(C#)
public static DateTime FromExcelSerialDate(int SerialDate)
{
if (SerialDate > 59) SerialDate -= 1; //Excel/Lotus 2/29/1900 bug
return new DateTime(1899, 12, 31).AddDays(SerialDate);
}
VB
Public Shared Function FromExcelSerialDate(ByVal SerialDate As Integer) As DateTime
If SerialDate > 59 Then SerialDate -= 1 ' Excel/Lotus 2/29/1900 bug
Return New DateTime(1899, 12, 31).AddDays(SerialDate)
End Function
[Update]:
好的:现在问题解决了.有关详细信息,请参阅 comments .