?
Solved

SQL server default language english- datetime & time columns

Posted on 2015-01-22
4
Medium Priority
?
124 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 69

Expert Comment

by:Scott Pletcher
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:
Scott Pletcher earned 2000 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Suggested Courses

777 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