databendlabs / databend

𝗗𝗮𝘁𝗮, 𝗔𝗻𝗮𝗹𝘆𝘁𝗶𝗰𝘀 & 𝗔𝗜. Modern alternative to Snowflake. Cost-effective and simple for massive-scale analytics. https://databend.com
https://docs.databend.com
Other
7.8k stars 742 forks source link

Issue with Converting Epoch Timestamp in Milliseconds to Date #16575

Open Shanmugavel-J opened 2 weeks ago

Shanmugavel-J commented 2 weeks ago

Summary

Getting different value when converting the below specific epoch timestamp in milliseconds to date. The function provides correct value when trying without milliseconds for that specific year.

Query: SELECT TO_TIMESTAMP(-7233803000);

Output: 1740-10-08 10:16:40.000

Query: SELECT TO_TIMESTAMP(-7233803);

Output: 1969-10-09 06:36:37.000

Note: The epoch time actual date is 1969-10-09

TCeason commented 2 weeks ago

By design

https://docs.databend.com/sql/sql-functions/datetime-functions/to-timestamp

Shanmugavel-J commented 2 weeks ago

@TCeason In the sense is that it would give it wrong?

I could see the correct date for remaining timestamps but not for that specific year(didnt check all the dates but for one or two days).

TCeason commented 2 weeks ago

In doc

Range Unit x < 31,536,000,000 Seconds 31,536,000,000 ≤ x < 31,536,000,000,000 Milliseconds x ≥ 31,536,000,000,000 Microseconds

Shanmugavel-J commented 2 weeks ago

@TCeason Okay. But the epoch time could be in negative as well correct? And if you could see i did a conversion of a date to epoch

I had attached the below image the epoch for date 10-10-1969 is shown in it. When that value is copied and executed in databend i get a different output.

image