DateAdd

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

Guest

I have entered a DateAdd for a default value in the Table. ("y",-1,Date())
This is to give me yesterdays Date. It worked fine until the SP3 update now
it does not function, I just get #name instead of yesterdays date. Can anyone
help me on this.
 
To subtract one day, use "d" in DateAdd(), i.e.:
DateAdd("d", -1, Date())

If that does not solve the problem, check your references by opening a code
window and choosing References on the Tools menu. More info on references
for each version of Access:
http://allenbrowne.com/ser-38.html
 
If you use Allen's function and it still doesn't work, try putting Nz in
front of the function :
Nz(DateAdd("d", -1, Date()))
I seem to recall that DateAdd can't handle fields with null value. Don't
know if that is the case, but it's one thing I thought of.
 
DateAdd() is fine with Null as the 3rd argument.

The first 2 arguments can't be null though.
You can see that easily if you look at the arguments displayed when you type
it: the first is String and the second is Double. Neither a String nor a
Double can be Null--only a Variant.

(Actually, the Double is somewhat misleading, as Access just "fixes" the
fractional part. Perhaps they used Double so it could handle values larger
than 2 billion.)
 
Back
Top