Date & Time functions

DAYS_PASSED

About

Calculates the cumulative number of days that have passed from a particular time period - from the start of the period to the end of a given 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_PASSED = LAMBDA(start_date, end_date, eom_dates,
    LET(
        som_dates, DATE(YEAR(eom_dates), MONTH(eom_dates), 1),
        min_end_date, BYCOL(eom_dates, LAMBDA(x, MIN(x, end_date))),
        days_passed, BYCOL(min_end_date - start_date + 1, LAMBDA(x, MAX(x, 0))),
        days_passed
    )
);