[AccessD] Pop-quiz: DateAdd() and negative time values

Gustav Brock gustav at cactus.dk
Thu Nov 20 03:08:33 CST 2003


Hi all

OK, this was a bit unfair as one option, the correct, was left out!
But that didn't fool you.

For a human the result should be:
f) 12/29/1899 11:00 PM

However, the result depends on the version.

Access 2.0 (!):
b) 12/30/1899 01:00 AM

Access 95, 97:
e) 12/30/1899 11:00 PM

Access 2000:
f) 12/29/1899 11:00 PM

I didn't go further but I guess Access XP and A2003 calculate it right
as A2000 does.

Also, Lambert's wording is more precise than mine:

.. the moral is not "Be careful with negative time values", but rather
look out for Dec 30 1899 and "negative additions" [for version 97 and
earlier].

/gustav


> Boring day.
> So here's a quick quiz to wake you up.

> The time value of #02:00 AM# equals

>    12/30/1899 02:00 AM

> What does - off your head - this expression return:

> ? Format(DateAdd("h", -3, #02:00 AM#),"mm\/dd\/yyyy hh\:nn AM/PM")

> a) 12/30/1898 11:00 PM
> b) 12/30/1899 01:00 AM
> c) 12/30/1899 05:00 AM
> d) 12/30/1899 05:00 PM
> e) 12/30/1899 11:00 PM

> The tricky part is DateAdd(). Format(), it is only for ensuring a
> consistent format of the return value.

> Morale: Be careful with negative time values for A97 and earlier.

> /gustav



More information about the AccessD mailing list