全部产品
阿里云办公

DAYOFMONTH

更新时间:2018-10-10 10:02:21

语法

  1. BIGINT DAYOFMONTH(TIMESTAMP time)
  2. BIGINT DAYOFMONTH(DATE date)

入参

  • date

    DATE类型

  • time

    TIMESTAMP类型

功能描述

返回输入时间参数date或time中所指代的“日”。返回值范围为1~31。

示例

  • 测试数据
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
  • 测试案例
  1. SELECT DAYOFMONTH(TIMESTAMP '2016-09-15 00:00:00') as int1,
  2. DAYOFMONTH(DATE '2017-09-22') as int2,
  3. DAYOFMONTH(tdate) as int3,
  4. DAYOFMONTH(ts) as int4,
  5. DAYOFMONTH(CAST(dateStr AS DATE)) as int5,
  6. DAYOFMONTH(CAST(tsStr AS TIMESTAMP)) as int6
  7. FROM T1
  • 测试结果
int1(BIGINT) int2(BIGINT) int3(BIGINT) int4(BIGINT) int5(BIGINT) int6(BIGINT)
15 22 10 15 15 15