Converts a Unix timestamp (in seconds) to a formatted date-time string.
Limits
This function is supported only in Realtime Compute for Apache Flink that uses Ververica Runtime (VVR) 3.0.0 or later.
Syntax
VARCHAR FROM_UNIXTIME(BIGINT unixtime[, VARCHAR format])Parameters
| Parameter | Data type | Required | Default | Description |
|---|---|---|---|---|
unixtime | BIGINT | Yes | — | A Unix timestamp in seconds since 1970-01-01 00:00:00 UTC. |
format | VARCHAR | No | yyyy-MM-dd HH:mm:ss | A Java datetime pattern string that controls the output format. For example, MMdd-yyyy outputs 0915-2017. |
If any input parameter is NULL or a parsing error occurs, the function returns NULL.
Examples
The following examples use the input value 1505404800.
Default format
SELECT FROM_UNIXTIME(1505404800);
-- Output: 2017-09-15 00:00:00Custom format
SELECT FROM_UNIXTIME(1505404800, 'MMdd-yyyy');
-- Output: 0915-2017NULL input
SELECT FROM_UNIXTIME(1505404800, NULL);
-- Output: NULL