Type: Function
Function: AFTER_N_TIMEPERIOD_WITH_OFFSET
Syntax: AFTER_N_TIMEPERIOD_WITH_OFFSET(date, number, period, offset)
Description: Returns true if the date is after 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.
AFTER_N_TIMEPERIOD_WITH_OFFSET(date, 12, "MONTH", "AGO") is the same as date >= NOW() - 12 * MONTH().
It is the same condition as the After (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:
AFTER_N_TIMEPERIOD_WITH_OFFSET(created_at, 12, "MONTH", "AGO")returnstruefor the records created in the last 12 months, counted from this instant.AFTER_N_TIMEPERIOD_WITH_OFFSET(due_on, 0, "HOUR", "FROM_NOW")returnstruefor the records due from now on.
