Skip to main content
Timestamp data types are used to store and process precise time information. RisingWave supports two types of timestamps:
  • timestamp: Stores date and time values without timezone, supporting up to nanosecond precision (9 digits after the decimal point).
  • timestamptz: Stores date and time values along with time zone information, supporting up to microsecond precision (6 digits after the decimal point).

Precision preservation

Added in version 2.1.
Nanosecond precision is fully maintained for timestamp during the following operations:
  • Reading from or writing to external sources (Kafka, Iceberg, Parquet, etc.) preserves nanoseconds automatically.
  • Adding or subtracting an interval from a timestamp.
    Add an interval
    SELECT '2022-03-13 01:00:00.123456789'::timestamp + INTERVAL '24' HOUR;
    -- Result: 2022-03-14 01:00:00.123456789
    
    Subtract an interval
    SELECT '2022-03-14 01:00:00.123456789'::timestamp - INTERVAL '24' HOUR;
    -- Result: 2022-03-13 01:00:00.123456789
    

Precision loss

Nanosecond precision is lost (truncated to microseconds or discarded) under the following scenarios:
  • Converting timestamp to types with lower precision:
    • timestamptz
    • time
    • date
  • Subtracting Timestamps (timestamp - timestamp): The result is an interval, which only has microsecond precision.
    Subtract two timestamps
    SELECT '2022-03-13 03:00:00.123456789'::timestamp - '2022-03-13 01:00:00.000000000'::timestamp;
    -- Result: 02:00:00.123456 (Note that nanosecond precision is truncated.)
    
For more functions and usage on timestamp, see Date and time functions and operators.