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?

I don't really understand your calculation. It seems you want to calculate how many times a given weekday (in your example, a Tuesday) occurs in a given date range (in your example, the period between today and the end of the current year). But I don't see anything in your input that would supply the weekday for the calculation to consider.

If you have the weekday, you can use the following generic formula to calculate how many times it occurs in the given range =

Let ( [

fullWeeks = Div ( EndDate ; 7 ) - Div ( StartDate ; 7 ) + 1 ;

subtract = ( weekDay < DayOfWeek ( StartDate ) ) + ( DayOfWeek ( EndDate ) < weekDay )

] ;

fullWeeks - subtract

)

where StartDate and EndDate are dates and weekDay is a number between 1 (Sunday) and 7 (Saturday).

Alternatively, consider a custom function like:

FileMaker Custom Function: WeekDaysInRange ( startDate ; endDate ; weekDays )

---

P.S. It is extremely bad practice to use $variables in Let () calculations; these variables continue to hang around until the end of the session, and may interfere with other calculations using the same variable names.