gpt4 book ai didi

c# - ASP 经典 : perform same subtraction of 2 dates and get the same value in C# value

转载 作者:行者123 更新时间:2023-11-30 22:55:27 25 4
gpt4 key购买 nike

我正在尝试从经典 ASP 切换到 ASP.Net MVC C#。有一部分我的 ASP Classic 代码将获得一个 DateTime 字段 A 然后将减去一个值 B 并将得到并回答 14322.4290162037 问题是我不知道如何在 C#

中获得相同的答案值
 response.write "A: ==The Value: 19/03/2019 10:17:47==" & rstPASS("DATELASTUSE") & "<br>"
response.write "B: ==The Value: 01/01/1980 === " & CDate("01/01/1980") & "<br>"
response.write "A - B: I get: 14322.4290162037 " & rstBROPASS("DATELASTUSE") - CDate("01/01/1980") & "<br>"

我尝试过的

 idtLastUse = dt.Rows[0]["DATELASTUSE"] - DateTime.ParseExact(s: "01-01-1980", format: "dd/MM/yy", provider: null);

最佳答案

您可以使用:

DateTime d1 = new DateTime(2019, 3, 19, 10, 17, 47);
DateTime d2 = new DateTime(1980, 1, 1, 0, 0, 0);
Console.WriteLine(d1.ToOADate() - d2.ToOADate());

查看 ToOADate 的文档以了解原因。

关于c# - ASP 经典 : perform same subtraction of 2 dates and get the same value in C# value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55238595/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com