Solved

Date formatting problems with server regional settings

Posted on 2013-10-29
5
754 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 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 50

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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

749 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