Adding to a DateDiff

kupe

Registered User.
Local time
Today, 22:32
Joined
Jan 16, 2003
Messages
462
Can I add another clause to a DateDiff function, making the second date minus 14 days.

Rather like DateDiff("d",[OneDate], Date - 14)

please Experts?
 
Last edited:
Rather like DateDiff("d",[OneDate], Date() - 14)

Look like it should work.

kh
 
It works, but it doesn't seem to work correctly, so I thought there may be some obvious fault. Thanks and cheers, Ken.
 
DateDiff("d",[OneDate], DateAdd("d", -14, Date()))
 
Hi Ken
It works sometimes and then not in another place. I haven't understood why yet. But I think SJ may have the answer, which I will try.
 
My mistake. I was overlooking a function in the form's query that does some of the work. Thanks very much, Ken, and SJ McAbney. (I've kept your suggestions for incorporation.) Cheers
 
Putting the date variation into the DateDiff function works fine, like

DateDiff("d",[OneDate], Date() - 14)

But I don't doubt really I should include SJ's DateAdd. Or .. perhaps there's some unwritten rule that says if it works, leave it alone. (?) Thanks, Ken, SJ.
 
SJ's DateAdd() method is what I think I will try to use for all my date() add subtract stuff in the future as it will provide a uniform method to do most date stuff. ie: I won't be looking back at my code and wonder how I arrived a value - Did I 'DateAdd()' or did I 'date()-10'. More of a clean coding issue I guess...


kh
 
Yes, that's a good point. I'll follow you. Cheers
 

Users who are viewing this thread

Back
Top Bottom