Skip to main content
The date_time_input_format setting selects the text parser for DateTime and DateTime64 values only. A Date or Date32 column has its own parser, which reads a date string only in the plain YYYY-MM-DD form, so a date with time such as 2018-06-08T01:02:03.000Z is rejected whatever the value of the setting. To load such values, read them as DateTime and convert them with toDate, or store the full timestamp.

Reproducing the error

The parser reads 2018-06-08, expects the value to end there, and finds T01:02:03.000Z instead. With INSERT ... VALUES the message is different, but the cause is the same:
Both inserts ran with date_time_input_format = 'best_effort', which is the default since ClickHouse 26.5 (basic before). The best_effort parser understands ISO 8601, but it is not used for Date and Date32 columns.

Convert the value during the insert

Describe the incoming data with the input table function. Declare the field as DateTime, so that the best_effort parser reads it, and convert it with toDate. With this events.jsonl file:
If you cannot change the query that the client sends, point the client at a landing table with the Null engine and let a materialized view do the same conversion:
An INSERT INTO events_landing FORMAT JSONEachRow with the same two rows inserts the same two rows into events.

Or keep the time

If the source sends a timestamp, you can store it as one and derive the date from it:

Mind the time zone

A string with Z or a UTC offset is a point in time, and its calendar date depends on the time zone in which you look at it. toDate uses the time zone of the DateTime value, which is the server or session time zone unless you set one. The examples above pin it to UTC. To keep the date exactly as it is written in the string, take its first 10 characters instead:
INSERT ... VALUES accepts a date with time that has no time zone suffix, such as '2018-06-08 01:02:03' or '2018-06-08T01:02:03.000', for a Date column and drops the time. This is specific to the Values format, which evaluates a value it cannot parse directly as an SQL expression. The same value is rejected in JSONEachRow, CSV and TSV, so do not rely on it.