Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

First of Month

Status
Not open for further replies.

HRISUser

Technical User
Nov 29, 2005
14
US
I am trying to set up a formula to calculate the first of the month after 30 days. So the field is called Benefit date let's say the value is 7/13/2006. I am trying to write a formula that will add 30 days (8/13/2006) and then display the first of the following month (9/1/2006). Any help would be greatly appreciated. Thanks!
 
Try:

whileprintingrecords;
NextMonth:=dateadd("D",30,currentdate);
FirstMonth:=dateserial(year(nextmonth),month(nextmonth)+1,1)

-k
 
Since you need to wrap the year for November dates (+30 days is December/1st of next month is a new year) you might need to use this formula...

IF Month (Date({TABLE.DATE})+30) = 12
THEN Date ((Year(Date({TABLE.DATE})+30)+1),1 ,1 )
ELSE Date (Year(Date({TABLE.DATE})+30),(Month(Date({TABLE.DATE})+30)+1) ,1 )
 
The dateserial function resolves your concerns, it automatically handles year handling as well.

-k
 
Thank you both for your quick response. It is nice for a newbie like myself to be able to get such great advice!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top