Solved

SQL server default language english- datetime & time columns

Posted on 2015-01-22
4
104 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: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 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Read about achieving the basic levels of HRIS security in the workplace.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

776 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