TIME_PERIOD_OFFSET

Calculates the number of time periods between a given date and the current period

Updated over a week ago

Description

The TIME_PERIOD_OFFSET() function calculates and returns the number of time periods (e.g., day, week, month, quarter, year, decade) between a given date or datetime and the current period. This is useful for determining how far a date is from the current time period.

Syntax

TIME_PERIOD_OFFSET(date, "day"/"week"/"month"/"quarter"/"year"/"decade")

Output

integer

Variables

  1. date: The date for which you want to calculate the time period offset.

  2. "day"/"week"/"month"/"quarter"/"year"/"decade": The time period to use for calculating the offset.

Example 1

TIME_PERIOD_OFFSET(`Event Date`,"day")

Event

Event Date

TIME_PERIOD_OFFSET(day)

Event A

September 10, 2023

−29

Event B

February 25, 2024

139

Event C

December 1, 2023

53

Event D

April 15, 2022

−542

Example 2

TIME_PERIOD_OFFSET(`Event Date`,"week")

Event

Event Date

TIME_PERIOD_OFFSET(week)

Event A

September 10, 2023

−5

Event B

February 25, 2024

19

Event C

December 1, 2023

7

Event D

April 15, 2022

−78

Example 3

TIME_PERIOD_OFFSET(`Event Date`,"month")

Event

Event Date

TIME_PERIOD_OFFSET(month)

Event A

September 10, 2023

−1

Event B

February 25, 2024

4

Event C

December 1, 2023

2

Event D

April 15, 2022

−18

Example 4

TIME_PERIOD_OFFSET(`Event Date`, "quarter")

Event

Event Date

TIME_PERIOD_OFFSET(quarter)

Event A

September 10, 2023

−1

Event B

February 25, 2024

1

Event C

December 1, 2023

0

Event D

April 15, 2022

−6

Example 5

TIME_PERIOD_OFFSET(`Event Date`,"year")

Event

Event Date

TIME_PERIOD_OFFSET(year)

Event A

September 10, 2023

0

Event B

February 25, 2024

1

Event C

December 1, 2023

0

Event D

April 15, 2022

−1

Example 6

TIME_PERIOD_OFFSET(`Event Date`,"decade")

Event

Event Date

TIME_PERIOD_OFFSET(decade)

Event A

September 10, 2023

0

Event B

February 25, 2024

0

Event C

December 1, 2023

0

Event D

April 15, 2022

0

*Examples As of September 22, 2023

Did this answer your question?