1

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.

2 Answers 2

2

This looks like seconds precision. QuestDb timestamp is in microseconds this cast should work

cast(unixDate * 1000000L AS TIMESTAMP)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, could you point me to the right directions in the docs to get this 1000000L?Would love to see more of these formats for other similar issues.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.