如何格式化SQL日期时间戳从BigInt到C#日期

发布于 2025-02-05 20:38:31 字数 304 浏览 3 评论 0原文

我需要将SQL视图中的日期从bigint值(格式: 20220504112601755 )转换为c#日期时间值(到某种类似的格式: 2022.05.04 11:26:01 < /strong> )在C#中。

我发现的只是Unix Epoch Times,以及如何将其转换为可读的日期时间,但对我的问题的情况并不多。

任何帮助将不胜感激。 (没有包含任何代码,因为我什至没有尝试过的任何代码都无法按照我的意愿工作

I need to convert dates in an SQL view from BIGINT value (format: 20220504112601755) to C# date time value (to some similar format: 2022.05.04 11:26:01) within C#.

All I found were unix epoch times and how to convert those to readable date times but not much about my issue.

Any help would be appreciated. (Didn't include any code because nothing I tried even came close to working as I wanted)

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云之铃。 2025-02-12 20:38:31

您需要使用datetime parseexact方法例如:

var date = DateTime.ParseExact("20220504112601755", "yyyyMMddhhmmssfff", System.Globalization.CultureInfo.InvariantCulture);

You need to use the DateTime ParseExact method e.g.:

var date = DateTime.ParseExact("20220504112601755", "yyyyMMddhhmmssfff", System.Globalization.CultureInfo.InvariantCulture);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文