Skip to main content
TIME_PERIOD

Returns a standard time period (e.g., day, week, month, quarter, year) for a given date or datetime field

Updated over a week ago

Description

The TIME_PERIOD() function assigns a standard time period, such as day, week, month, quarter, or year, to a given date or datetime field. This is useful for organizing and aggregating data into consistent time intervals for analysis and reporting.

Syntax

TIME_PERIOD(date, "day"/"week"/"month"/"quarter"/"year")

Output

text

Variables

  1. date: The date or datetime field for which you want to determine the time period.

  2. "day"/"week"/"month"/"quarter"/"year": Specifies the standard time period.

The “week” time period groups from Monday to Sunday.

Example 1

TIME_PERIOD(`Sale Date`, 'year')

Transaction

Sale Date

TIME_PERIOD(year)

Transaction A

2023-09-10

2023

Transaction B

2023-08-25

2023

Transaction C

2023-09-01

2023

Example 2

TIME_PERIOD(`Sale Date`, 'quarter')

Transaction

Sale Date

TIME_PERIOD(quarter)

Transaction A

2023-09-10

2023 Q3

Transaction B

2023-08-25

2023 Q3

Transaction C

2023-09-01

2023 Q3

Example 3

TIME_PERIOD(`Sale Date`,'month')

Transaction

Sale Date

TIME_PERIOD(month)

Transaction A

2023-09-10

2023-09

Transaction B

2023-08-25

2023-08

Transaction C

2023-09-01

2023-09

Example 4

TIME_PERIOD(`Sale Date`,'week')

Transaction

Sale Date

TIME_PERIOD(week)

Transaction A

2023-09-10

2023-09-04

Transaction B

2023-08-25

2023-08-21

Transaction C

2023-09-01

2023-08-28

Example 5

TIME_PERIOD(`Sale Date`,'day')

Transaction

Sale Date

TIME_PERIOD(day)

Transaction A

2023-09-10

2023-09-10

Transaction B

2023-08-25

2023-08-25

Transaction C

2023-09-01

2023-09-01

Did this answer your question?