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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reoccurring date formula 1

Status
Not open for further replies.

dazum

Technical User
Apr 6, 2011
57
US
I have a formula that calculates a meeting date that reoccurs every 180 days starting with the trigger date. Below is a portion of the formula;
If currentdate - {@trigger} <= 180
then dateadd("d", 180, {@trigger})
else
if currentdate - {@trigger} > 180 and currentdate - {@trigger} <= 360
then dateadd("d", 360, {@trigger})
else
if currentdate - {@trigger 1} > 360 and currentdate - {@trigger} <= 540 then dateadd("d", 540, {@trigger})........

Is there a more efficient way this formula can be written? The formula works, but becomes cumbersome the more years away you are from the trigger date. I am using CR 11.
 
maybe something like this (i cannot test it at the moment so apologize in advance for any errors/typos):

{@FutureTDate}
numbervar dv := int((currentdate - {@MtgDate})/180);
numbervar td := (dv)+1 * 180;
dateadd("d", td, {@MtgDate});
 
You just need to change the parens for td:

//{@FutureTDate};
numbervar dv := int((currentdate - {@MtgDate})/180);
numbervar td := (dv+1) * 180;
dateadd("d", td, {@MtgDate});

I tried something fancier using a loop, but this does the job more simply (*).

-LB
 
The formula works great! It calculates the meeting date automatically no matter how many years away from the trigger date you get.
Thanks for all who helped on this formula!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top