Stepan Yakovenko
Stepan Yakovenko

Reputation: 9206

Clickhouse: how to convert date to long integer?

I have date as a string field in form of '2018-01-02 12:12:22', what is the right way to convert it to long int timestamp in ClickHouse SQL?

Upvotes: 6

Views: 6854

Answers (2)

Ilya
Ilya

Reputation: 728

My query returns a different result

SELECT toUInt64(toDateTime('2018-01-02 12:12:22', 'UTC'))

┌─toUInt64(toDateTime('2018-01-02 12:12:22', 'UTC'))─┐
│                                         1514895142 │
└────────────────────────────────────────────────────┘

Upvotes: 0

Ivan Blinkov
Ivan Blinkov

Reputation: 2554

:) SELECT toUInt64(toDateTime('2018-01-02 12:12:22'));

SELECT toUInt64(toDateTime('2018-01-02 12:12:22'))

┌─toUInt64(toDateTime('2018-01-02 12:12:22'))─┐
│                                  1514884342 │
└─────────────────────────────────────────────┘

1 rows in set. Elapsed: 0.001 sec.

Upvotes: 7

Related Questions