Solved

SQL server default language english- datetime & time columns

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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 setup several different housekeeping processes for a SQL Server.

910 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

21 Experts available now in Live!

Get 1:1 Help Now