Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Date formatting problems with server regional settings

Posted on 2013-10-29
5
Medium Priority
?
812 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 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 52

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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
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.

886 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