Remaining Weekly Occurrences For The Month

Discussion created by cmj on Dec 26, 2018
Latest reply on Dec 30, 2018 by cmj

I have a calculation that determines a budget amount remaining based on an item that repeats weekly.


Let (


$BudgetNet = Income::IncBudgetAmt;

$Cdate = Get(CurrentDate);

$Wk_YrEnd = WeekOfYear(Date(12;31;Year(Get(CurrentDate))));

$WkYr_Cdate = WeekOfYear(Get(CurrentDate));



$BudgetNet*($Wk_YrEnd - $WkYr_Cdate)


The problem with this calculation is that it does not consider the day of  the week.


For example, if the income item takes place on a Tuesday (eg. Dec 25th.)  and today is Dec.26th. , the calculation above results in 1 more occurrence before the end of the year (since the end of the year is during the following week).


Since there are no more Tuesdays in this month, the calc should = 0.


Any thoughts on how to modify this calculation so it considers if any more Tuesdays take place before the end of the current month?