Working with timestamps
Processing and storing temporal data are common activities in data analysis and data management. DuckDB provides data types and functions specifically for working with data that represent times, dates, intervals, and timestamps. Timestamps are combinations of dates and times that are frequently used in data analytics contexts, especially when working with time series datasets. Timestamps can sometimes be a misunderstood concept, so in this section, we’ll introduce some principles for thinking about working with timestamp data in DuckDB before jumping into some examples of working with timestamps.
Timestamps represent distinct points in time, often referred to as instants. DuckDB has two data types for representing timestamps: TIMESTAMP
and TIMESTAMP WITH TIME ZONE
. The latter type is also available as the alias TIMESTAMPZ
, which we’ll use from here on for brevity. These are both used to store date and time information. As you might have guessed...