简体   繁体   中英

Type “Time” in SQL Server and C#

有没有什么办法可以在C#中创建类型时间以与SQL服务器的类型时间兼容?

According to MSDN:

Mapping CLR Parameter Data

You're looking for the TimeSpan type.

try using the below date formatter in C#.

DateTime dateTime = DateTime.Now; 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'

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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