简体   繁体   English

如何将 SQL 日期时间戳从 Bigint 格式化为 C# 日期

[英]How to format SQL date timestamp from Bigint to C# date

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#.我需要在 C# 中将 SQL 视图中的日期从 BIGINT 值(格式: 20220504112601755 )转换为 C# 日期时间值(转换为某种类似的格式: 2022.05.04 11:26:01 )。

All I found were unix epoch times and how to convert those to readable date times but not much about my issue.我发现的只是 unix 纪元时间以及如何将它们转换为可读的日期时间,但对我的问题并不多。

Any help would be appreciated.任何帮助,将不胜感激。 (Didn't include any code because nothing I tried even came close to working as I wanted) (没有包含任何代码,因为我尝试过的任何东西都没有接近我想要的工作)

Thanks谢谢

您需要使用DateTime ParseExact方法,例如:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM