Skip to main content

WITHIN_DATES

Written by Tom Williams

Type: Function

Function: WITHIN_DATES

Syntax: WITHIN_DATES(date, from, to, [granularity])

Description: Returns true if the date is between the two dates, both included, 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.

It is the same condition as the Within (dates) 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:

  • WITHIN_DATES(created_at, "2026-01-01", "2026-03-31") returns true for the records created in the first quarter of 2026, 31 March included.

  • WITHIN_DATES(merged_at, "2026-01-01", "2026-06-01", "YEAR_MONTH") returns true for the pull requests merged from January to June 2026.

Did this answer your question?