Converts a date or timestamp value into a UNIX timestamp (BIGINT).
Limitations
This function is supported only in Realtime Compute for Apache Flink that uses Ververica Runtime (VVR) 3.0.0 or later.
Syntax
BIGINT UNIX_TIMESTAMP(VARCHAR date)
BIGINT UNIX_TIMESTAMP(TIMESTAMP timestamp)
BIGINT UNIX_TIMESTAMP(VARCHAR date, VARCHAR format)Input parameters
| Parameter | Data type | Description |
|---|---|---|
date | VARCHAR | A date string to convert. Default format: yyyy-MM-dd HH:mm:ss. |
timestamp | TIMESTAMP | A TIMESTAMP value to convert. |
format | VARCHAR | The format pattern for parsing date. Default: yyyy-MM-dd hh:mm:ss. |
Examples
Basic conversion
Test data (table T1)
| date1 (VARCHAR) | date2 (VARCHAR) |
|---|---|
| 2021-03-25 00:00:00 | 1970-01-01 00:00:00 |
Test statement
SELECT UNIX_TIMESTAMP(TO_TIMESTAMP_TZ(date1, 'Asia/Shanghai')) AS big1,
UNIX_TIMESTAMP(date2) AS big2
FROM T1;Test result
| big1 (BIGINT) | big2 (BIGINT) |
|---|---|
| 1616601600 | -28800 |