[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL server default language english- datetime & time columns

Posted on 2015-01-22
4
Medium Priority
?
167 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 70

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 70

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

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

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
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…

872 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