Solved

Dateadd

Posted on 2016-11-19
3
20 Views
Last Modified: 2016-11-19
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.
0
Comment
Question by:pdvsa
3 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 41894085
try

[ValueDateDD]=DateSerial(Year([ValueDateDD]),Month([ValueDateDD])+4,Day([ValueDateDD]))
0
 

Author Closing Comment

by:pdvsa
ID: 41894091
nice.  thank you Rey..
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 41894120
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
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now