Hitachi

Hitachi Advanced Database SQL Reference


8.9.2 DAYOFWEEK

Returns the day of the week that the specified date falls on. Note that the first day of the week is Sunday.

Organization of this subsection

(1) Specification format

scalar-function-DAYOFWEEK ::= {DAYOFWEEK|DOW}(target-data)
 
  target-data ::= value-expression

Note: DOW can be used as an abbreviated form for DAYOFWEEK.

(2) Explanation of specification format

target-data:

Specifies the data representing the day.

The following rules apply:

  • Specify the target data in the form of a value expression. For details about value expressions, see 7.20 Value expression.

  • The data type of the target data must be DATE, TIMESTAMP, CHAR, or VARCHAR. In the case of CHAR or VARCHAR, you must specify a character string literal that adheres to the predefined input representation formats. For details about the predefined input representations, see 6.3.3 Predefined character-string representations.

  • You cannot specify a dynamic parameter by itself for the target data.

The following example illustrates the result of executing the scalar function DAYOFWEEK.

Example

Return an integer value indicating the day of the week that September 12, 2012 falls on.

DAYOFWEEK(DATE'2012-09-12')4

September 12, 2012 is a Wednesday, so it returns 4.

(3) Rules

  1. The data type of the execution result is INTEGER.

  2. The NOT NULL constraint does not apply to the value of the execution result (the null value is allowed).

  3. If the target data has the null value, the execution result will be a null value.

  4. The relationship between the value of the execution result and the day of the week is shown in the following table.

    Table 8‒25: Relationship between the value of the execution result and the day of the week

    Value of execution result

    Day of week

    1

    Sunday

    2

    Monday

    3

    Tuesday

    4

    Wednesday

    5

    Thursday

    6

    Friday

    7

    Saturday

(4) Example

Example:

Return an integer value that indicates the day of the week for the data in column C2 in table T1.

SELECT "C1",DAYOFWEEK("C2") FROM "T1"

[Figure]