Timestamp, interval, and date examples
Examples that use the event time of Kafka tables, convert timestamps, and filter by time intervals.
In these examples, eventTimestamp is the Kafka record timestamp, which Cloudera SQL Stream Builder (SSB) adds
to Kafka tables as a TIMESTAMP_LTZ(3) column. For more information, see
Using the default Kafka timestamps.
Get the latest event time
SELECT MAX(eventTimestamp)
FROM solar_inputs;
Convert the event time to a string
SELECT CAST(MAX(eventTimestamp) AS VARCHAR) AS ts
FROM solar_inputs;
Get the date of each event
SELECT CAST(eventTimestamp AS DATE) AS event_date
FROM solar_inputs;
Return the payments from the last 10 seconds
SELECT *
FROM payments
WHERE eventTimestamp > CURRENT_TIMESTAMP - INTERVAL '10' SECOND;
