Solved

Date formatting problems with server regional settings

Posted on 2013-10-29
5
727 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
Comment Utility
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
Comment Utility
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 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
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…

744 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

7 Experts available now in Live!

Get 1:1 Help Now