如何使用linq从sqlserver数据库中获取时间 [英] how to get time from sqlserver data base using linq
本文介绍了如何使用linq从sqlserver数据库中获取时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Date Time.Now函数将日期存储在数据库中。日期存储在数据库中(例如,2014-03-28 18:39:18.250)。当我使用查询获取此时间时,转换时间意味着显示6:39:18.250。我希望时间格式正确(18:39:18.250)
解决方案
访问:希望其中一个可能有用
http://www.csharp-examples.net/string-format-datetime/ [ ^ ]
试试这个
DateTime nowTime = DataContext.GetServerDate();
基本上你自己回答了!
字符串类型有许多格式选项(标准和自定义)!
DateTime yourDate;
// ...获取dateTime值
string formattedTime = yourDate.ToString( hh: MM:SS跨度>);
I store date in database using Date Time.Now function. The date is stored in database like(ex 2014-03-28 18:39:18.250). when i fetch this time using query then the time is converted means show 6:39:18.250 . I want the time in correct format means (18:39:18.250)
解决方案
Visit: Hopefully one of them may be useful
http://www.csharp-examples.net/string-format-datetime/[^]
Try this
DateTime nowTime = DataContext.GetServerDate();
Basically you answered it yourself!
string type has many formatting options (standard and custom)!
DateTime yourDate; //... getting dateTime value string formattedTime = yourDate.ToString("hh:mm:ss");
这篇关于如何使用linq从sqlserver数据库中获取时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文