Solved

Dateadd

Posted on 2016-11-19
3
42 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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 50

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

734 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