[英]Get Timestamp difference in ksql
I need to calculate the difference of the two timestamp in KSQL confluent.cloud.我需要计算 KSQL confluent.cloud 中两个时间戳的差异。
Below are my queries,以下是我的查询,
SELECT
ENTITY -> IENTITYID,
ENTITY -> DTINSERTDATE,
ENTITY -> DTUPDATEDATE,
HEADERS -> OPERATION,
TIMESTAMPTOSTRING(ROWTIME, 'yyyy-MM-dd HH:mm:ss.SSS') AS rowtime_formatted,
CAST(ENTITY -> DTUPDATEDATE AS TIMESTAMP) AS UpdatedDateFROMtblEntity
FROM tblEntity
EMIT CHANGES
LIMIT 10;
Here, I have two timestamp such as ROWTIME and UpdatedDateFROMtblEntity.在这里,我有两个时间戳,例如 ROWTIME 和 UpdatedDateFROMtblEntity。 So, how to calculate the difference on those timestamps?.那么,如何计算这些时间戳的差异? I need this in milliseconds.我需要以毫秒为单位。 Please help me to resolve this issues.请帮我解决这个问题。
SELECT UNIX_TIMESTAMP(col1) - UNIX_TIMESTAMP(col2)
FROM STREAM1 EMIT CHANGES;
Reference: https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-reference/scalar-functions/#unix_timestamp参考: https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-reference/scalar-functions/#unix_timestamp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.