Type: Function
Function: BEFORE_N_TIMEPERIOD_WITH_OFFSET
Syntax: BEFORE_N_TIMEPERIOD_WITH_OFFSET(date, number, period, offset)
Description: Returns true if the date is before the number of periods ago, or from now.
The period is "HOUR", "DAY", "WEEK", "MONTH", "QUARTER" or "YEAR", in upper or lower case.
The offset is "AGO" or "FROM_NOW", in upper or lower case.
The limit is measured from this instant and is not rounded to the start of a period: 12 months ago is this very moment, 12 months back. To work with whole periods, use LAST_N_TIMEPERIOD, CURRENT_TIMEPERIOD or NEXT_N_TIMEPERIOD.
BEFORE_N_TIMEPERIOD_WITH_OFFSET(date, 12, "MONTH", "AGO") is the same as date <= NOW() - 12 * MONTH().
It is the same condition as the Before (from/ago) filter of the insight designer (see Using filters). Use it in a custom formula, to count, group or label records on that condition, or as a filter in a query sent through the Keypup API or MCP server.
Sample usage:
BEFORE_N_TIMEPERIOD_WITH_OFFSET(created_at, 30, "DAY", "AGO")returnstruefor the records created more than 30 days ago.BEFORE_N_TIMEPERIOD_WITH_OFFSET(due_on, 0, "HOUR", "FROM_NOW")returnstruefor the records whose due date has passed.
