Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL DateTime Format

Status
Not open for further replies.

DarkConsultant

Programmer
Dec 4, 2007
156
GB
Hi All,

I do not know what the protocol is but I have posted this on two forums ...

I had to move a db from one server to another and several of the tables store DateTime data.

On the old server they appeared in Management Studio as dd/MM/yyyy (I will ignore the time part as this is not an issue). On the new server they appear as MM/dd/yyyy.

When this data is returned to the client I use CDate(<server data>).ToString("dd/MM/yyyy") to get the data. On the old entries I get good data but when I convert any new entries I get bad data (MM/dd/yyyy) so 12th of November becomes 11th of December.

Can the server be persuaded to return the data the same as the old entries or is there some way to detect what format I am getting?

TIA

DarkConsultant

Live long and prosper \\//
 
Check the language setting of login you use to connect to the database.

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Please read this:


I would encourage you to make sure the default language for the server is set to British English, and then make sure that all the logins are set that way to.

You may need to manually clean up some data if it is stored in the database with the month and day reversed already.


-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Hi Again,

I had already found the article and changed the language to english but this made no difference.

Yah I am cleaning it as I go along.

I have just installed a new table with a datetime column and manually inserted getdate() into it. The formatting and returns were perfect.

So I launched my app on both servers and stopped it before it sent an insert with a datetime column in it and both apps are sending in yyyy-mm-dd (ignoring time part) format.

The old server is perfect, the new server is badly formatted. If I try to insert a date that cannot be reversed like 13/10/2011 (cannot be 10/13/2011) the app reports an error.

DarkConsultant

Live long and prosper \\//
 
What do you get when you run this:

Code:
select Distinct Language from sys.syslogins

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
I'm no expert but could this also not be affected by the short date format setting located in the regional settings of the computer?

If at first you don't succeed, then sky diving wasn't meant for you!
 
Hi BlueJay,

If only life was that simple ...

I have instigated a workaround which is working so I will put this to bed as unsolved ... unless anyone knows different!

Heartfelt thanks to all contributers.

DarkConsultant

Live long and prosper \\//
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top