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

Syntax

BIGINT DAYOFMONTH(TIMESTAMP time)
BIGINT DAYOFMONTH(DATE date)

Input parameters

Parameter Data type
date DATE
time TIMESTAMP

Description

Returns the day component of the specified date or time value. The return value ranges from 1 to 31.

Example

  • Test data
    tsStr (VARCHAR) dateStr (VARCHAR) tdate (DATE) ts (TIMESTAMP)
    2017-10-15 00:00:00 2017-09-15 2017-11-10 2017-10-15 00:00:00
  • Test statements
    SELECT DAYOFMONTH(TIMESTAMP '2016-09-15 00:00:00') as int1,
     DAYOFMONTH(DATE '2017-09-22') as int2,
     DAYOFMONTH(tdate) as int3,
     DAYOFMONTH(ts) as int4,
     DAYOFMONTH(CAST(dateStr AS DATE)) as int5,
     DAYOFMONTH(CAST(tsStr AS TIMESTAMP)) as int6
    FROM T1; 
  • Test results
    int1 (BIGINT) int2 (BIGINT) int3 (BIGINT) int4 (BIGINT) int5 (BIGINT) int6 (BIGINT)
    15 22 10 15 15 15