v.20.9Improvement

Add Precision Argument for DateTime Type

Add precision argument for DateTime type. It allows to use DateTime name instead of DateTime64. #13761 (Winter Zhang).
Added a precision argument to the DateTime type, allowing users to specify precision and use DateTime as an alias for DateTime64.

Why it matters

This feature solves the confusion and limitation between DateTime and DateTime64 types by enabling DateTime to represent date-time values with specified precision. It simplifies type usage and enhances flexibility when working with date and time data.

How to use it

When defining a column or casting to a date-time type, specify the precision argument with the DateTime type, for example: DateTime(3) to indicate millisecond precision. This behaves like DateTime64(3). For example:

CREATE TABLE example (
event_time DateTime(3)
) ENGINE = MergeTree()
ORDER BY event_time;