all-things-risingwave
How to convert Epoch time to timestamp?
I have an Epoch time value (e.g., 1686650137175) that I need to convert to a timestamp. When using to_timestamp() function, I encountered an error. How can I achieve this conversion?
Se
Sereena Eldhose
Asked on Jul 06, 2023
- To convert Epoch time to timestamp, you can use the following SQL query:
SELECT TO_TIMESTAMP('1686650137.175');
This query accepts epoch time in seconds.
- If your timestamp value is in milliseconds (e.g., "timestamp":1688534502958), you can use the following SQL query to convert it:
SELECT TO_TIMESTAMP(CAST(1688534502958 AS DECIMAL) / 1000);
This query first casts the value to decimal and then divides it by 1000 to convert milliseconds to seconds before converting to a timestamp.
Jul 07, 2023Edited by