Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Date formatting problems with server regional settings

Posted on 2013-10-29
5
Medium Priority
?
799 Views
Last Modified: 2013-10-30
I have an application that consists of an Access 2010 FE with a SQL Server 2012 BE.  This application has been evolving over approximately 20 years, and has seen many different programmers, I am simply the current programmer.
The way that the program has been coded, requires users to have their short date format set to month/day/year, which Windows has declared to be US format (I am in Canada).  We also have the SQL Server login set to MDY.  We have a client that is experiencing a problem with the dates in the program, that we believe is caused by the following combination:
The date format on the server that is hosting the SQL Server is set to mm/dd/yy.  A 2 digit year.
The server interprets 2 digit years a being between 1900 and 1999.
This is causing formatting problems with some of the date fields throughout the program.  The program is using a four digit year in some places and a two digit year in others.  In some instances of the two digit year, it has the year correct as 2013, and in other locations, it interprets the two digit year as 1913.
I am wondering if there is a way to overcome this problem.  In the locations that the program is misinterpreting the date, I have tried to explicitly format to a four digit year, and that is not solving the problem.

Thanks
Zharphyn
0
Comment
Question by:Zharphyn
[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
5 Comments
 
LVL 31

Expert Comment

by:hnasr
ID: 39610122
Compare the 2 client machines.
Date and time settings control panel
Change date and time
Change calendar settings
Calendar: When a two-digit year is entered.
0
 

Author Comment

by:Zharphyn
ID: 39610304
Sorry, I was not more clear.  I was wondering if there is a programmatic solution to the problem.  Is there a way that I can programmatically have the server computer return its short date format settings, and the date range it uses to translate a 2-digit year?  Is there a way that I can force the program to use a four digit year, when the server is using a 2-digit year?  I am trying to make the program work in all circumstances, or failing that, to provide feedback to the client telling them why their result sets are incorrect.

Thanks
Zharphyn
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 39610503
try something like this in a query

select [datefield], cdate(iif(right([datefield],2) < "50", left([datefield],6) & "20" & right([datefield],2), left([datefield],6) & "19" & right([datefield],2))) as dteField
from tableX


adjust the value "50" as necessary, depending on the date values in your table.
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 39610990
By default SQL Server 2012 does not use the date settings from the hosting server.
The default date format is yyyy-mm-dd.

Thus, it is more likely that the issue is how the front end writes the date values to the tables of SQL Server. Also, if you use and write values of data type Date, it has no format, only the value, thus such values can never fail.

So it looks like you need to debug the frontend for any improper SQL.
When you find some, we can tell you how to correct it.

/gustav
0
 
LVL 31

Expert Comment

by:hnasr
ID: 39611101
To automate things, you need to understand the problem.
Are the 2 clients with different data sets, have the same date and time settings?
http:#a39610122
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

715 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