The UTC range for 2022 starts at 1640995200 and ends at the exclusive boundary 1672531200. The year has 365 days.

Use the year as a half-open range

WHERE event_time >= 1640995200
  AND event_time <  1672531200

The exclusive upper boundary is safer than “December 31 at 23:59:59.” It works whether the database stores whole seconds, milliseconds, or fractions of a second.

Month starts in UTC

Month start Unix seconds ISO 8601 UTC
January 1 1640995200 2022-01-01T00:00:00Z
February 1 1643673600 2022-02-01T00:00:00Z
March 1 1646092800 2022-03-01T00:00:00Z
April 1 1648771200 2022-04-01T00:00:00Z
May 1 1651363200 2022-05-01T00:00:00Z
June 1 1654041600 2022-06-01T00:00:00Z
July 1 1656633600 2022-07-01T00:00:00Z
August 1 1659312000 2022-08-01T00:00:00Z
September 1 1661990400 2022-09-01T00:00:00Z
October 1 1664582400 2022-10-01T00:00:00Z
November 1 1667260800 2022-11-01T00:00:00Z
December 1 1669852800 2022-12-01T00:00:00Z

Quarter boundaries

  • Q1: 1640995200 (2022-01-01T00:00:00Z)
  • Q2: 1648771200 (2022-04-01T00:00:00Z)
  • Q3: 1656633600 (2022-07-01T00:00:00Z)
  • Q4: 1664582400 (2022-10-01T00:00:00Z)
  • Next year: 1672531200 (2023-01-01T00:00:00Z)

These are UTC values. If the business timezone is not UTC, its local year begins at a different instant; calculate those boundaries in the named location before storing the result.