EXCEL导入日期变为数字
作者:互联网
private static string ToDateTimeValue(string warehouseTime)
{
if (!string.IsNullOrWhiteSpace(warehouseTime))
{
Decimal tempValue;
if (Decimal.TryParse(warehouseTime, out tempValue))
{
int day = Convert.ToInt32(Math.Truncate(tempValue));
DateTime dt = new DateTime(1900, 1, 1).AddDays(day < 32 ? (day - 1) : (day - 2));
return dt.ToString("yyyy-MM-dd");
}
else
{
return warehouseTime;
}
}
return string.Empty;
}
标签:warehouseTime,return,string,EXCEL,DateTime,日期,导入,tempValue,day 来源: https://blog.csdn.net/xiaoting_feng/article/details/120429622