Why doensn't this work (1 Viewer)

Jimmy

New member
Local time
Today, 21:31
Joined
Sep 13, 2004
Messages
6
Hi everyone,

dateadd("d",-1,date()) this doesn't work
dateadd("d",-1,#13-9-2004#) this works great

But i need the first solution. I always need the date of yesterday

Can somebody help me!!
 

adaytay

Not your typical IT Geek!
Local time
Today, 20:31
Joined
May 14, 2004
Messages
16
Jimmy said:
Hi everyone,

dateadd("d",-1,date()) this doesn't work
dateadd("d",-1,#13-9-2004#) this works great

But i need the first solution. I always need the date of yesterday

Can somebody help me!!

Try being a little more expressive, and storing Date() in a variable before passing through to DateAdd.

Something like:

Code:
Dim dtDate as Date

dtDate=Date()

DateAdd("d", -1, dtDate)

This is untested, but should work...

Ad
 
R

Rich

Guest
Where are you using it? there are no brackets after Date in vba, it's just Date
 

ray705

Registered User.
Local time
Today, 14:31
Joined
Feb 3, 2003
Messages
45
I just tried your format on a form linked to a command button. Worked perfectly. How are you trying to use it?
 
R

Rich

Guest
ecniv said:
dateadd("d",-1,now)
Now will add a time element into the equation and give inconsistent results, Date is correct, if it isn't working then Jimmy almost certainly has a missing reference
 

Jimmy

New member
Local time
Today, 21:31
Joined
Sep 13, 2004
Messages
6
Thx ADAYTAY you were right, pretty obvious :) strange that date() doesn't return a date-obeject.

Thank you all for you replies (Y)

adios
 

Users who are viewing this thread

Top Bottom