DateAdd different result in India than US recently

BlueKarana
BlueKarana used Ask the Experts™
on
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

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
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.


Author

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...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial