问题转化为格式日期 [英] problem into format date
本文介绍了问题转化为格式日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我想在项目中使用"dd/MM/yyyy"格式,因此我将其更改为sql显示格式,并在服务器和iis7 LCID上将其更改为英语UK,但是sql server仍使用"MM/dd/yyyy"格式,因此
hello,
i want to use "dd/MM/yyyy" format in my project so i changed it into sql display format and on my server and on iis7 LCID to English UK but sql server still use format "MM/dd/yyyy" so
推荐答案
从表名中选择convert(varchar,date,103)作为日期
在从SQL Server提取数据时使用它.
select convert(varchar,date,103) as date from tablename
use it while fetching data from sql server.
Sql并不关心格式,除非您将DateTime的值作为字符串而不是DateTime
(您通常应该避免将DateTime返回为DateTime以外的任何值).前端是您控制格式(显示方式)的地方.您可以这样操作:
Sql doesn''t care about format unless you''re returning the DateTime ''s value as a string instead of aDateTime
(you should generally avoid returning a DateTime as anything but a DateTime). The front end is where you control the format (how it''s displayed). You can do that like this:
// globally accessible culture object
using System.Threading;
System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
在sql中需要mm/dd/yyyy.但是,您可以在代码中进行更改. like,0 string dt = DateTime.Now.ToString("dd/MM/yyyy");
In sql it takes mm/dd/yyyy. But in code you can change it. like,0 string dt=DateTime.Now.ToString("dd/MM/yyyy");
这篇关于问题转化为格式日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文