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

Charlotte Foust cfoust at infostatsystems.com
Wed Nov 19 13:17:47 CST 2003


Why would it return any of those values, Gustav?  Since the date is
implied, removing 3 hours from it is going to kick it into the previous
day.

Charlotte Foust

-----Original Message-----
From: Gustav Brock [mailto:gustav at cactus.dk] 
Sent: Wednesday, November 19, 2003 9:40 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Pop-quiz: DateAdd() and negative time values


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.

/gustav

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list