如何将一个18位数转换成Excel中可读的日期格式?

huangapple go评论58阅读模式
英文:

How can I convert an 18digit number to a human-readble date in Excel?

问题

在Excel中如何将18位数字转换为可读的日期?

根据标题,如何在Excel中将18位数字(例如634019142119225390)转换为可读的日期?

在PowerShell中,以下似乎是实现此目的的方法:

$timeStamp = 634019142119225390 / 10000000
$epochTime= [datetime]"01/01/0001 00:00:00"
$epochTime.AddSeconds($timeStamp)
英文:

How to convert 18 digits value into human-readable date in excel?

As per the title, how to covert 18 digits numbers (eg.634019142119225390) into human-readable date in excel?

In Powershell the following seems to be the way to do so:

$timeStamp = 634019142119225390/ 10000000
$epochTime= [datetime]"01/01/0001 00:00:00"
$epochTime.AddSeconds($timeStamp)

答案1

得分: 3

以下是翻译好的部分:

这是一个示例,说明如何执行以下操作:

首先,将时间戳值除以 10,000,000,将其从100纳秒间隔转换为秒。
然后,从结果中减去62,135,596,800,将其从.NET纪元(0001年1月1日)转换为Unix纪元(1970年1月1日)。
最后,将结果添加到DATE(1970,1,1)函数中,以获取最终的日期值。
以下是一个将单元格A1中的时间戳值转换为可读日期的示例公式:

=DATE(1970,1,1)+((A1/10000000)-62135596800)/86400

复制这个

该公式将单元格A1中的时间戳值除以10,000,000,并减去62,135,596,800,将其从.NET纪元转换为Unix纪元。然后,将结果添加到DATE(1970,1,1)函数中,并除以86,400(一天中的秒数)以获取最终的日期值。

然后,您可以将结果单元格格式设置为日期。

请检查我是否理解正确。

英文:

I guess you are trying to do below:

Here’s an example of how you can do that:

First, divide the timestamp value by 10,000,000 to convert it from 100-nanosecond intervals to seconds.
Then, subtract 62,135,596,800 from the result to convert it from the .NET epoch (January 1, 0001) to the Unix epoch (January 1, 1970).
Finally, add the result to the DATE(1970,1,1) function to get the final date value.
Here’s an example formula that converts the timestamp value in cell A1 into a human-readable date:

=DATE(1970,1,1)+((A1/10000000)-62135596800)/86400

Copy this

This formula divides the timestamp value in cell A1 by 10,000,000 and subtracts 62,135,596,800 to convert it from the .NET epoch to the Unix epoch. It then adds the result to the DATE(1970,1,1) function and divides by 86,400 (the number of seconds in a day) to get the final date value.

You can then format the resulting cell as a date.

Please check if i get this right

huangapple
  • 本文由 发表于 2023年5月21日 18:29:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76299426.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定