Math on the Date/Time function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How, if possible, can I add anumber to the date function. I have code with a
statement similar to

![DateNow] = Date + ??

which gives a type mismatch. I would like to have DateNow equal to 1 more
than the current date. Thanks in advance

Nick
 
How about:
![DateNow] = Date + 1

Assuming DateNow is a Date/Time variable that should work
 
ndunwoodie said:
How, if possible, can I add anumber to the date function. I have code with a
statement similar to

![DateNow] = Date + ??

which gives a type mismatch. I would like to have DateNow equal to 1 more
than the current date.


If you look under the covers, you'll see that the integer
part of a date (which is stored as a Double) is the number
of days since 30 Dec 1899. This means that adding an
integer value such as 7 will result in a date 7 days from
today.

However, you should not be working "under the covers".
Instead, you should use the built-in functions DateAdd and
DateDiff to manipulate date values. E.g.
DateAdd("d", 7, Date)
or
DateAdd("ww", 1, Date)
both result in a date 7 days (or one week) from today.
 
Back
Top