Skip to main content

CURRENT_TIMEPERIOD

Written by Tom Williams

Type: Function

Function: CURRENT_TIMEPERIOD

Syntax: CURRENT_TIMEPERIOD(date, period)

Description: Returns true if the date is within the current period.

The period is "HOUR", "DAY", "WEEK", "MONTH", "QUARTER" or "YEAR", in upper or lower case.

The current period runs from its start to its end: this month is from the 1st to the last day of the month, including the days still to come.

It is the same condition as the Current 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:

  • CURRENT_TIMEPERIOD(created_at, "QUARTER") returns true for the records created this quarter.

  • COUNT_IF(CURRENT_TIMEPERIOD(closed_at, "WEEK")) as a metric counts the records closed this week.

Did this answer your question?