This topic describes how to use the date function SECOND in Realtime Compute.

Syntax

BIGINT SECOND(TIMESTAMP timestamp)
 BIGINT SECOND(TIME time)    

Input parameters

Parameter Data type
time TIME
timestamp TIMESTAMP

Description

Returns the second component of a specified time value. The return value ranges from 0 to 59.

Example

  • Test data
    datetime1 (VARCHAR) time1 (VARCHAR) time2 (TIME) timestamp1 (TIMESTAMP)
    2017-10-15 11:12:13 22:23:24 22:23:24 2017-10-15 11:12:13
  • Test statements
    SELECT SECOND(TIMESTAMP '2016-09-20 23:33:33') as int1,
     SECOND(TIME '23:30:33') as int2,
     SECOND(time2) as int3,
     SECOND(timestamp1) as int4,
     SECOND(CAST(time1 AS TIME)) as int5,
     SECOND(CAST(datetime1 AS TIMESTAMP)) as int6
    FROM T1;   
  • Test results
    int1 (BIGINT) int2 (BIGINT) int3 (BIGINT) int4 (BIGINT) int5 (BIGINT) int6 (BIGINT)
    33 33 24 13 24 13