I've been assigned a bugfix where a particular bit of script that selects the appropriate connection has suddenly started to fail:
if formatdatetime(dateStr, 1) = formatdatetime(now(), 1) then
With cn
.ConnectionString= ShapeConnection
.CommandTimeout = .ConnectionTimeout
.Open
End With
elseif formatdatetime(dateStr, 1) < formatdatetime(now(), 1) then
With cn
.ConnectionString = Apollo2ShapeConnection
.CommandTimeout = .ConnectionTimeout
.Open
End With
end if
where dateStr is a date selected by the user in a dd-mm-yyyy format. The comparison is failing in both cases and so no connection is being selected. I've changed the code to the following and now it works fine:
if cdate(dateStr) = cdate(now()) then
With cn
.ConnectionString= ShapeConnection
.CommandTimeout = .ConnectionTimeout
.Open
End With
elseif cdate(dateStr) < cdate(now()) then
With cn
.ConnectionString = Apollo2ShapeConnection
.CommandTimeout = .ConnectionTimeout
.Open
End With
end if
It does work now so I'm happy enough with that. What I really dont understand is the original bit of script is used in quite a few pages, and in all these other pages it still works fine. All the pages are on the server and all recieve the dateStr variable in the same format. I've passed the same date into both pages, in one case it fails, in the other it works. WHY?!?
Any ideas about this would be greatly appreciated! It is severely messing with my head!
Cheers :)