Skip to main content

BEFORE_DATE

Written by Tom Williams

Type: Function

Function: BEFORE_DATE

Syntax: BEFORE_DATE(date, other_date, [granularity])

Description: Returns true if the date is before the other date, at the chosen granularity (the day by default).

The granularity is "YEAR", "YEAR_QUARTER", "YEAR_MONTH", "YEAR_WEEK" or "YEAR_MONTH_DAY", in upper or lower case, and defaults to "YEAR_MONTH_DAY". Both dates are compared at that level: by default, a record created at any time of a day matches that day.

BEFORE_DATE(date, other_date, "YEAR_MONTH") is the same as LESS_THAN(YEAR_MONTH(date), YEAR_MONTH(other_date)).

It is the same condition as the Before (date) 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_DATE(created_at, "2026-03-03") returns true if the record was created up to 2 March 2026.

  • BEFORE_DATE(created_at, "2026-03-01", "YEAR_MONTH") returns true if the record was created up to February 2026.

Did this answer your question?