[英]Type “Time” in SQL Server and C#
有没有什么办法可以在C#中创建类型时间以与SQL服务器的类型时间兼容?
According to MSDN: 根据MSDN:
Mapping CLR Parameter Data 映射CLR参数数据
You're looking for the TimeSpan type. 您正在寻找TimeSpan类型。
try using the below date formatter in C#. 尝试在C#中使用以下日期格式化程序。
DateTime dateTime = DateTime.Now; DateTime dateTime = DateTime.Now; string text = dateTime.ToString("yyyy'-'MM'-'dd HH':'mm':'ss.fff"); string text = dateTime.ToString(“yyyy' - 'MM' - 'dd HH':'mm':'ss.fff”);
This will lead to the same format as sql date format 'yyyy-mm-dd hh:mm:ss.fff' 这将导致与sql日期格式'yyyy-mm-dd hh:mm:ss.fff'相同的格式
Thanks! 谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.