DAYOFWEEK Function

Description

The DAYOFWEEK function returns a day in the range of 1 to 7 (1: Sunday, 2: Monday, ..., 7: Saturday) from the specified parameters. The day index is same as the ODBC standards. You can specify the DATE, TIMESTAMP, or DATETIME type; the value is returned in INTEGER type.

If every argument value of date and time is 0, the return value is determined by the return_null_on_function_errors system parameter; if it is set to yes, then NULL is returned; if it is set to no, an error is returned. The default value is no.

Syntax

DAYOFWEEK(date)

Example

SELECT DAYOFWEEK('2010-09-09');

   dayofweek('2010-09-09')

==========================

                         5

 

SELECT DAYOFWEEK('2010-09-09 19:49:29');

 dayofweek('2010-09-09 19:49:29')

=================================

                                5

 

SELECT DAYOFWEEK('10:28:00');

ERROR: Conversion error in date format.

 

SELECT DAYOFWEEK('0000-00-00');

ERROR: Conversion error in date format.