Link to home
Start Free TrialLog in
Avatar of pdvsa
pdvsaFlag for United States of America

asked on

Dateadd

Experts,

How would I add 4 months to [ValueDateDD]
[ValueDateDD]=DLookUp("ValueDate","tblDraws_Details1","ID = " & [DrawIDrpmt])

add 4 months:
=[ValueDateDD]+DateAdd("m",4,DLookUp("ValueDate","tblDraws_Details1","ID = " & [DrawIDrpmt]))
=[ValueDateDD]+DateAdd("m",4,[ValueDateDD])
both of those add many years and not 4 months.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdvsa

ASKER

nice.  thank you Rey..
Your error is that you add ValueDate to itself plus four months.
That, of course, results in a date about 2016 + (2016 - 1899) = about 2136.

So your first expression is correct - just leave out [ValueDateDD]:

    =DateAdd("m",4,DLookUp("ValueDate","tblDraws_Details1","ID = " & [DrawIDrpmt] & ""))

However, if [ValueDateDD] holds the same value as you would look up - which I suspect it does - it is even simpler, as in your second expression:

    =DateAdd("m",4,[ValueDateDD])

So, as Rey would know if he had had his morning coffee, no need for a deroute via DateSerial.

/gustav