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

Syntax

BIGINT EXTRACT(unit FROM time)

Input parameters

Parameter Data type
time Any date expression.
unit Valid values:
  • MICROSECOND
  • SECOND
  • MINUTE
  • HOUR
  • DAY
  • WEEK
  • MONTH
  • QUARTER
  • YEAR
  • SECOND_MICROSECOND
  • MINUTE_MICROSECOND
  • MINUTE_SECOND
  • HOUR_MICROSECOND
  • HOUR_SECOND
  • HOUR_MINUTE
  • DAY_MICROSECOND
  • DAY_SECOND
  • DAY_MINUTE
  • DAY_HOUR
  • YEAR_MONTH

Description

Returns separate parts from the date or time value, for example, the year, month, day, hour, minute, or week.

Example

  • Test statements
    EXTRACT(YEAR FROM CURRENT_TIMESTAMP) AS OrderYear,
    EXTRACT(MONTH FROM CURRENT_TIMESTAMP) AS OrderMonth,
    EXTRACT(DAY FROM CURRENT_TIMESTAMP) AS OrderDay,
    EXTRACT(WEEK FROM CURRENT_TIMESTAMP) AS OrderWeek    
  • Test results
    OrderYear (BIGINT) OrderMonth (BIGINT) OrderDay (BIGINT) OrderWeek (BIGINT)
    2018 10 11 41