DateAdd different result in India than US recently

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!)

<% '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)
			  	'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

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BlueKaranaAuthor Commented:
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...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.