Reputation: 980
I have created a table coming from CSV upload which has a unix timestamp in the form of 1613775600
. At import phase, QuestDB casts it as Int
.
How can I set this field as the TIMESTAMP
column ?
I tried this in my SELECT:
cast(unixDate AS TIMESTAMP)
but it does not correctly parses the unix date, giving inconsistent dates.
Upvotes: 1
Views: 781
Reputation: 1465
This looks like seconds precision. QuestDb timestamp is in microseconds this cast should work
cast(unixDate * 1000000L AS TIMESTAMP)
Upvotes: 2
Reputation: 980
For now I used this trick:
dateadd('s', unixDate, to_timestamp('1970-01-01T00:00:00+0000', 'yyyy-MM-ddTHH:mm:ssZ'))
which basically adds XXXXXXXXXX
seconds to the UTC date of January 1st, 1970
.
Works quite well actually.
Upvotes: 1