← Back to Glossary

timestamps

Timestamps are a fundamental data type in databases and programming languages that represent a specific point in time, typically including both the date and…

Timestamps are a fundamental data type in databases and programming languages that represent a specific point in time, typically including both the date and time down to a precise level such as seconds or milliseconds. In DuckDB, timestamps can be stored and manipulated using the TIMESTAMP data type. They are particularly useful for tracking when events occur, logging changes, or performing time-based analytics.

To work with timestamps in DuckDB, you can use functions like NOW() to get the current timestamp, or create timestamps from strings using CAST or the :: operator. For example:

Related terms

FAQS

A timestamp is a data type representing a specific point in time, typically date plus time down to seconds or milliseconds. It's used for tracking events, logging changes, and time-based analytics.

Cast a string with CAST('2023-05-01 14:30:00' AS TIMESTAMP) or the shorthand '2023-05-01 14:30:00'::TIMESTAMP, and get the current time with NOW().

Use EXTRACT(YEAR FROM ts) (or MONTH, DAY, etc.), and do date math with intervals, for example ts + INTERVAL '1 day'.