Skip to main content

Command Palette

Search for a command to run...

Time Series functions in BigQuery

Updated
1 min read
Time Series functions in BigQuery
C

Senior Data Engineer • Contractor / Freelancer • GCP & AWS Certified

I've posted some time ago about "rounding" timestamps and datetime values, but in the past few months BigQuery has added Time Series functions (in preview for now), making for a cleaner and simpler approach of this problem.

We now have DATE_BUCKET, DATETIME_BUCKET and TIMESTAMP_BUCKET which will help us bucket dates, datetimes and timestamps, respectively.

In the example below, we're specifying the bucket size to be 15 minutes and the function groups each of our event_timestamps into their respective bucket.

Found it useful? Subscribe to my Analytics newsletter at notjustsql.com.

Practical SQL

Part 1 of 50

Short, practical posts on SQL and BigQuery — from core language features to advanced query patterns. A reference for data practitioners at every level.

More from this blog

D

Datawise — SQL, BigQuery & Python for Data Engineers

205 posts

Data Engineer with a passion for transforming complex data landscapes into insightful stories. Here on my blog, I share insights, challenges, and the ever-evolving dance of technology and business.