Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 431
Stepan Yakovenko Avatar asked Sep 16 '18 18:09

Stepan Yakovenko


1 Answers

:) 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.
like image 156
Ivan Blinkov Avatar answered Oct 23 '22 21:10

Ivan Blinkov