ClickHouse Functions/Date Functions

toStartOfQuarter

Round a DateTime to the first day of the quarter for QoQ reporting.

Signature

toStartOfQuarter(datetime: DateTime): Date

Returns

Date

What it does

Rounds a DateTime or Date down to the first day of its calendar quarter: Jan 1, Apr 1, Jul 1, or Oct 1. Returns a Date. Used for quarterly business reporting.

toStartOfQuarter is essential for enterprise and SaaS analytics where business targets are quarterly: ARR growth, quarterly churn, Q-o-Q retention. It buckets any date into one of four annual quarters so GROUP BY produces one row per quarter.

Notes

  • Calendar quarters only — Jan–Mar, Apr–Jun, Jul–Sep, Oct–Dec. Fiscal quarter offsets need manual arithmetic.
  • Combine with toStartOfYear for year-over-year quarterly comparisons.

Example SQL

toStartOfQuarter in ClickHouse SQL

toStartOfQuarter-example.sql

TypeScript with hypequery

Use toStartOfQuarter in a typed TypeScript query

hypequery gives you a type-safe query builder for ClickHouse. The generated schema maps your ClickHouse columns to TypeScript types, and raw SQL expressions let you incorporate functions like toStartOfQuarter when you need them inside a builder query.

quarterly-arr.ts

Common questions

What developers search for with toStartOfQuarter

ClickHouse quarterly aggregation

toStartOfQuarter maps every date to one of four dates per year. GROUP BY on the result gives quarterly totals directly.

Quarter-over-quarter growth ClickHouse

Use toStartOfQuarter in a self-join or window function to compare each quarter's metric against the previous one.

FAQ

Frequently asked questions about toStartOfQuarter

Does ClickHouse support fiscal quarters?

Not natively. For fiscal quarters offset from calendar quarters, add the offset in days before calling toStartOfQuarter, or use toStartOfInterval with a custom INTERVAL.

Related functions

Functions used alongside toStartOfQuarter

Next step

Use toStartOfQuarter in a type-safe TypeScript query

hypequery generates TypeScript types from your ClickHouse schema. Use toStartOfQuarter alongside the builder, and reach for raw SQL expressions when the function is not exposed as a dedicated helper.