Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

DateAdd different result in India than US recently

Posted on 2008-11-12
2
Medium Priority
?
275 Views
Last Modified: 2013-11-19
We have a corporate site that has been in use in the US for a long time and now in the last few months employees in India have begun to use it.

The code in question uses the vbscript DateAdd function to add 90 days to the current date. It worked until this week (I don't have an exact date for the start of the problem) as expected in both the US and in India, that is, it would add 90 days properly. Now, it works in the US but in India the resultant date is 81 days out instead of 90.

E.g., Today an Indian user visited the site and got an expiration date of February 1, 2008. It should be February 10th.

Is there an explanation for this sudden change?

(I know we've had the Day Light Savings time change in the US but that doesn't seem to have any bearing on this...a 9 day discrepancy!)

Thanks.
<% 'Figure out what the default expiration date should be 
		      ' 90 days for a Temporary badge, 1 year for Contractor 
			  sTodaysDate = Date
			  response.write "Date = " & 	sTodaysDate		  
			  'DateAdd will Compensate for Leap Day
			  If (InStr(UCase(rsPerson.Fields.Item("person_type_description").Value), "TEMPORARY") > 0) Then
			    'This is a Temporary, set default date to 90 days in future
					sExpDate = DateAdd("d", 90, sTodaysDate)
			  Else
			  	'This is a Contractor, set default date to 1 year in future
				'DateAdd will Compensate for Leap Day
					sExpDate = DateAdd("yyyy", 1, sTodaysDate)				
			  End If
			  
			sDefaultMonth = Month(sExpDate)
			sDefaultDay = Day(sExpDate)
			sDefaultYear = Year(sExpDate)
		  %>

Open in new window

0
Comment
Question by:BlueKarana
2 Comments
 
LVL 15

Accepted Solution

by:
SRigney earned 1000 total points
ID: 22940103
Most likely this is an internationalization issue with one of the functions you are using.   I'm not finding which one quickly.   If you can, find out what the locale is set to for the India users and try to reproduce it by changing your local settings to that local.

My guess is that by assigning Date to sTodaysDate, it's formatting it based on the locale, which is part of what is causing you problems,  If you pass Date in to the DateAdd function it may work better.


0
 

Author Closing Comment

by:BlueKarana
ID: 31515939
I think you're on to something. It turns out I missunderstood the person who told me about this. The problem is actually in the form validation with a call to DateDiff. Same problem though.

This is the call:

DateDiff("d", SysDate, sDate)

The variables values look like this going in: DateDiff("d", "11/12/2008", "2/10/2009")

For a regional setting of United States the result is 90, for Germany it is 295. DateDiff obviously uses the date format specified in the local regional setting internally. This code is called after submit so it's performed locally, not server-side so it makes sense that this would happen. (The person in India has gone home for the night so I just picked a region I know is DD/MM/YYYY.)

Next I need to figure out how to make this more globally aware...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Over time, the online landscape has altered considerably, but that’s nothing compared to the up-and-coming trends that will shape the web design industry in the coming year. Keep reading to find out which trends will shape B2B web design in 2018.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

580 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