v.22.9Improvement

Allow String to Date and Date32 Conversion for DateTime Formats

Allow conversion from String with DateTime64 like 2022-08-22 01:02:03.456 to Date and Date32. Allow conversion from String with DateTime like 2022-08-22 01:02:03 to Date32. This closes #39598. #40475 (Alexey Milovidov).
Enable conversion from String containing DateTime64 or DateTime formatted values to Date and Date32 types.

Why it matters

This feature addresses the need to directly convert string representations of date and time with fractional seconds (DateTime64) or standard DateTime format to the Date and Date32 data types in ClickHouse. It simplifies data ingestion and processing by allowing users to handle such conversions without additional parsing or transformation steps.

How to use it

Users can simply cast or convert String values like '2022-08-22 01:02:03.456' or '2022-08-22 01:02:03' to Date or Date32. For example:

SELECT CAST('2022-08-22 01:02:03.456' AS Date)

or
SELECT CAST('2022-08-22 01:02:03' AS Date32)