The UTC range for 2020 starts at 1577836800 and ends at the exclusive boundary 1609459200. The year has 366 days.

Use the year as a half-open range

WHERE event_time >= 1577836800
  AND event_time <  1609459200

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 1577836800 2020-01-01T00:00:00Z
February 1 1580515200 2020-02-01T00:00:00Z
March 1 1583020800 2020-03-01T00:00:00Z
April 1 1585699200 2020-04-01T00:00:00Z
May 1 1588291200 2020-05-01T00:00:00Z
June 1 1590969600 2020-06-01T00:00:00Z
July 1 1593561600 2020-07-01T00:00:00Z
August 1 1596240000 2020-08-01T00:00:00Z
September 1 1598918400 2020-09-01T00:00:00Z
October 1 1601510400 2020-10-01T00:00:00Z
November 1 1604188800 2020-11-01T00:00:00Z
December 1 1606780800 2020-12-01T00:00:00Z

Quarter boundaries

  • Q1: 1577836800 (2020-01-01T00:00:00Z)
  • Q2: 1585699200 (2020-04-01T00:00:00Z)
  • Q3: 1593561600 (2020-07-01T00:00:00Z)
  • Q4: 1601510400 (2020-10-01T00:00:00Z)
  • Next year: 1609459200 (2021-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.