Date & Time functions

DAYS_IN_MONTH.PCT

About

Calculates the number of days from a particular time period, that occur within a particular month. Results shown as a percentage, instead of days.

Calls DAYS_IN_MONTH.

Inputs:

  • start_date : start date of time period
  • end_date : end date of time period
  • eom_dates : a horizontal vector of month end dates

Code

M.S. Excel
DAYS_IN_MONTH.PCT = LAMBDA(start_date, end_date, eom_dates,
    LET(
        days_in_month, DAYS_IN_MONTH(start_date, end_date, eom_dates),
        total_days, MAX(end_date - start_date + 1, 0),
        percent_days_in_month, days_in_month / total_days,
        IFERROR(percent_days_in_month, "check dates!")
    )
);