Solved

Date formatting problems with server regional settings

Posted on 2013-10-29
5
742 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
5 Comments
 
LVL 30

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 500 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 49

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 30

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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Viewers will learn how the fundamental information of how to create a table.

792 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