开发者

SQL Server stores the date in the format specified in the regional setting

My computer regional setting is in the UK English format.

I am saving the date in the US format as a string from my program to SQL Sever 2008 Enterprise Edition.

But when I view the table, I see the date has been saved in the UK format . The data type of the table is nvarchar2000)

开发者_如何学JAVA

In a nutshell, I want to save the dates in the US format , irrespective of the regional settings.

Thanks Sujay


since your saving to nvarchar then you wont be abl to control it from SQL Server,

so i bet your chance is to change the date before saving it

you can :

var ci = new CultureInfo("en-US");// i think en-gb is for united kingdom but not sure
fieldvalue = yourdate.ToString("d", ci);

then you save fieldvalue instead..

also you can use ToString("MM/DD/YYYY"); to convert date to specific format if your not sure what culture to use, but know how you want the string to be in sql server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜