Click to copy

• Reviewed for ksqlDB 0.29

How to Get Record Timestamp in ksqlDB

Use the pseudo-column ROWTIME to get the record timestamp in milliseconds since EPOCH :

SELECT 
  flight_id,
  ROWTIME,
  FROM_UNIXTIME(ROWTIME) as ROWTIME_TS
FROM flights
LIMIT 1;

that returns :

+-------------------------+-------------------------+-------------------------+
|ROWTIME                  |ROWTIME_TS               |FLIGHT_ID                |
+-------------------------+-------------------------+-------------------------+
|1657876520019            |2022-07-15T09:15:20.019  |373780                   |
ROWTIME is of type BIGINT, so remember that you can use the function FROM_UNIXTIME to convert it to the TIMESTAMP type. Then use FORMAT_TIMESTAMP if you need a particular timestamp format.
Discover what readers are saying
topictale
Get easy to digest how-tos on ksqlDB
Sign up
Please read our Privacy Policy to understand how we protect and manage your data.
You may also like