Solved

SQL server default language english- datetime & time columns

Posted on 2015-01-22
4
98 Views
Last Modified: 2015-01-28
Hi Experts,

I'm working on a large product that has hundreds of queries that involve DateTime and Time columns on SQL Server.  We are experiencing a problem when our application uses an SQL server where the default language is not English.

The reason- we are using the format string "YYYY-MM-DD hh:mm:ss" and not "YYYY-MM-DDThh:mm:ss"

So my question is, are there any shortcuts for me here?  Is the best case to go through each query that touches a DateTime or Time column and change it to this format?  When reading from the database, will I have to convert again?

I know this is vague, but I'm at the "trying to understand the problem" phase.

Thanks,
Mike
0
Comment
Question by:thready
  • 2
  • 2
4 Comments
 
LVL 69

Expert Comment

by:ScottPletcher
ID: 40565149
You can add the statement:
SET DATEFORMAT mdy
to the start of the proc if all date literals are in that format.

Btw, for the future, the format below always works, and is shorter and more natural:
"YYYYMMDD hh:mm:ss"
0
 
LVL 1

Author Comment

by:thready
ID: 40565159
What do you mean by "start of the proc"?  I have code in a gazillion files that do individual update/insert /select all over the place... Is there a global way to ensure a customer's machine uses only our database format in this way?
0
 
LVL 69

Accepted Solution

by:
ScottPletcher earned 500 total points
ID: 40565173
No, not if they have a default language that has a different date setting, afaik.

"Start of the proc" =
CREATE PROC ...
AS
SET NOCOUNT ON;
SET DATEFORMAT mdy
...rest of proc...
0
 
LVL 1

Author Closing Comment

by:thready
ID: 40576652
Thanks  :)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Creating and Managing Databases with phpMyAdmin in cPanel.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now