Skip to content

how to insert/update date/datetime field #38418

Answered by den-crane
flyly0755 asked this question in Q&A
Discussion options

You must be logged in to vote

https://clickhouse.com/docs/en/sql-reference/data-types/datetime64/

https://clickhouse.com/docs/en/operations/settings/settings/#date_time_input_format

CREATE TABLE default.test_tb
(
test_fd1 DateTime,
id Int8
)
ENGINE = MergeTree
ORDER BY test_fd1
SETTINGS index_granularity = 8192;

set date_time_input_format='best_effort';

insert into TABLE test_tb(id, test_fd1) values(1, '2022-03-25 22:35:47.000');

insert into TABLE test_tb(id, test_fd1) values(2, cast('2022-03-25 22:35:47.000','DateTime64(3)'));

select * from test_tb;

┌────────────test_fd1─┬─id─┐
│ 2022-03-25 22:35:471 │
└─────────────────────┴────┘
┌────────────test_fd1─┬─id─┐
│ 2022-03-25 22:35:472 │
└───────────────────…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@flyly0755
Comment options

@den-crane
Comment options

@den-crane
Comment options

@flyly0755
Comment options

@den-crane
Comment options

Answer selected by den-crane
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants