Maria
Maria

Reputation: 45

Dates are replaced by 1970-01-01 when inserting into clickhouse

I'm trying to insert data into a clickhouse table. Data is inserted but I got dates from 1970 (it may be 1970-01-01 or 1970-02-02 etc.) Why can this be happening? I have several fields with dates, but the problem only relates to one of them. I woupld expect to have 1970 if there was null in the inserting select, but it is not the case. So I got 1970 instead of a noraml value.

Upvotes: 0

Views: 875

Answers (2)

SANTHOSH.SJ
SANTHOSH.SJ

Reputation: 441

use DateTime64

SELECT toDateTime64('1960-11-11',3) AS datetime64_example;

doc link

Upvotes: 0

A date. Stored in two bytes as the number of days since 1970-01-01 (unsigned). Allows storing values from just after the beginning of the Unix Epoch to the upper threshold defined by a constant at the compilation stage (currently, this is until the year 2149, but the final fully-supported year is 2148).

Supported range of values: [1970-01-01, 2149-06-06]. from enter link description here

If the inserted date is not within this range, it will be converted to 1970-01-01

Upvotes: 0

Related Questions