[thelist] ASP dateadd error

Scott Schrantz scotts at rci-nv.com
Mon Jul 15 17:07:36 CDT 2002


> -----Original Message-----
> From: Feingold Josh S [mailto:Josh.S.Feingold at irs.gov]
>
> Anyone know why
>
> dateadd("h",-1,time())
>
> returns 12/29/1899 11:XX:XX PM (where XX is anywhere from 00 to 59).
>
> The error only happens from 12:00 Midnight to 1:00 AM.

Try it with Now(), see if it works better.

DateAdd("h",-1,Now())

I think it's because Time() doesn't have any awareness of the current date,
and when you try to go back to "yesterday" it forces a date.
Obviously, it picks New Year's 1900.
You can always display just the Time portion of a Date variable:

Response.Write FormatDateTime(DateAdd("h",-1,Now()), vbLongTime)

--
Scott Schrantz
work: www.rci-nv.com
play: www.computer-vet.com



More information about the thelist mailing list