Here is a formula I did to calculate the storage days in the warehouse last month. Think of receiving inventory of Clients and then shipping 'em out again! Not so different from rolls of steel coils where the storage fee is per day and they look back to the previous month to cut an invoice for all coils stored last month. The formula makes use for formula variables for readability

https://help.quickbase.com/user-assistance/formula_variables.htmlvar date ShipDate = [BTC Discharge Date];

var date ReceivedDate = [BTC Admission Date];

var date FirstDayofPriorMonth = AdjustMonth(FirstDayOfMonth(Today()),-1);

var date LastDayofPriorMonth = LastDayOfMonth($FirstDayofPriorMonth);

var date FirstDayStoredPriorMonth = If(

$ReceivedDate <= $LastDayofPriorMonth and (IsNull($ShipDate) or $ShipDate >= $FirstDayofPriorMonth),

Max($FirstDayofPriorMonth, $ReceivedDate));

var date LastDayStoredPriorMonth = If(

IsNull($ShipDate) and not IsNull($FirstDayStoredPriorMonth), $LastDayofPriorMonth,

not IsNull($FirstDayStoredPriorMonth) and $ShipDate >= $FirstDayofPriorMonth, Min($ShipDate,$LastDayofPriorMonth));

var number DaysStoredPriorMonth = If(

IsNull($ReceivedDate]),0,

not IsNull($LastDayStoredPriorMonth), ToDays($LastDayStoredPriorMonth - $FirstDayStoredPriorMonth));

$DaysStoredPriorMonth