View Single Post
  #2 (permalink)  
Old November 22nd, 2004, 04:17 PM
bluckcuck bluckcuck is offline
Friend of Wrox
 
Join Date: May 2003
Posts: 202
Thanks: 0
Thanked 1 Time in 1 Post
Default

It should be fixed now.

It was a strange ASP date comparison issue. Apparently 10/31/2004 02:00:00 doesn't compare the same as 10/31/2004 02:00:00 [u]AM</u>.

The code that builds the end date for DST starts with the last day in October at 2:00am and while that day is not a Sunday, subtracts one day. The goal is to find the last Sunday in October. This year it was 10/31 so the loop didn't have to iterate.

The code looked like this:
Code:
endDate = "10/31/" & currentYear & " 02:00:00"
while DatePart("w",endDate) <> 1
    endDate=DateAdd("d",-1,endDate)
wend
The result of this code for this year is 10/31/2004 02:00:00 since no loops were required (10/31 was a Sunday).

Strangely enough, the following test returns true (when it should fail):
Code:
startDate = "04/04/2004 02:00:00 AM"
endDate = "10/31/2004 02:00:00"

if (now() >= startDate) and (now() <= endDate) then
    'Adjust for daylight savings time
end if
Notice the missing "AM" on the endDate. Adding that back in makes the test work correctly. The reason the code failed this year is because no loops were required. The DateAdd function would add the "AM" back on to the date.

Very strange.

Bruce Luckcuck
Director, Applications & Support Services
Wiley Publishing, Inc.