doc-exports/docs/dli/sqlreference/dli_spark_quarter.html
Su, Xiaomeng 76a5b1ee83 dli_sqlreference_20240227
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
2024-03-27 22:02:33 +00:00

5.9 KiB

quarter

This function is used to return the quarter of a date. The value ranges from 1 to 4.

Syntax

quarter(string date)

Parameters

Table 1 Parameter

Parameter

Mandatory

Type

Description

date

Yes

DATE

or

STRING

Date that needs to be processed

The following formats are supported:
  • yyyy-mm-dd
  • yyyy-mm-dd hh:mi:ss
  • yyyy-mm-dd hh:mi:ss.ff3

Return Values

The return value is of the INT type.

  • If the value of date is not of the DATE or STRING type, the error message "data type mismatch" is displayed.
  • If the value of date is of the DATE or STRING type but is not in one of the supported formats, NULL is returned.
  • If the value of date is NULL, NULL is returned.

Example Code

The value 3 is returned.

select quarter('2023-08-16 10:54:00');

The value 3 is returned.

select quarter('2023-08-16');

The value NULL is returned.

select quarter(null);