Computing an End Date

D

Dwight

I need to determine an end date by adding a set number of years to the start
date and then taking the date to the end of the month.

Here is what I use to have but the requirement changed to the last day of
the month.

!TEND = DateAdd("d", -1, DateAdd("yyyy", !Tenure, !NewTourDt))

Thanks in advance for any help you can provide me.

Dwight
 
B

boblarson

There may be a more elegant way but this should work:

!TEND = DateSerial(Year(DateAdd("d", -1, DateAdd("yyyy", !Tenure,
!NewTourDt)),Month(DateAdd("d", -1, DateAdd("yyyy", !Tenure, !NewTourDt)+1),0)
--
Bob Larson
Access MVP
Access World Forums Administrator
Utter Access VIP

Tutorials at http://www.btabdevelopment.com

__________________________________
 
J

Jeff Boyce

Dwight

Take a look at the DateSerial() function. A trick you can use is to add one
to the month, then use the "0"th day. This will always get you the last day
of the previous month. First do your DateAdd(), then use DateSerial().

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
F

fredg

I need to determine an end date by adding a set number of years to the start
date and then taking the date to the end of the month.

Here is what I use to have but the requirement changed to the last day of
the month.

!TEND = DateAdd("d", -1, DateAdd("yyyy", !Tenure, !NewTourDt))

Thanks in advance for any help you can provide me.

Dwight
Using the DateSerial function, the last day of any month is the 0 day
of the following month.
Let's add 5 years to the [ADate] field.

=DateSerial(Year(DateAdd("yyyy",5,[ADate])),Month(DateAdd("yyyy",5,[ADate]))+1,0)

Change [ADate] to whatever the appropriate field name is.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top