DateAdd

D

David

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.
 
A

Allen Browne

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
 
B

BruceM

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.
 
A

Allen Browne

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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top