v.20.9Improvement
Add Precision Argument for DateTime Type
Add precision argument forDateTimetype. It allows to useDateTimename instead ofDateTime64. #13761 (Winter Zhang).
Why it matters
This feature solves the confusion and limitation betweenDateTime 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 theprecision 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;