VeloDB Cloud
SQL Manual
Functions
date-time-functions
weekday

weekday

Description

Syntax:

INT WEEKDAY (DATETIME date)

This function returns the index value of the weekday of the date (Monday = 0, Tuesday = 2, and Sunday = 6).

The parameter can be of DATE or DATETIME type. It can also be any number that can be casted into a DATE or DATETIME type.

Please note the difference between WEEKDAY and DAYOFWEEK:

          +-----+-----+-----+-----+-----+-----+-----+
          | Sun | Mon | Tues| Wed | Thur| Fri | Sat |
          +-----+-----+-----+-----+-----+-----+-----+
  weekday |  6  |  0  |  1  |  2  |  3  |  4  |  5  |
          +-----+-----+-----+-----+-----+-----+-----+
dayofweek |  1  |  2  |  3  |  4  |  5  |  6  |  7  |
          +-----+-----+-----+-----+-----+-----+-----+

Example

mysql> select weekday('2019-06-25');
+--------------------------------+
| weekday('2019-06-25 00:00:00') |
+--------------------------------+
|                              1 |
+--------------------------------+

mysql> select weekday(cast(20190625 as date)); 
+---------------------------------+
| weekday(CAST(20190625 AS DATE)) |
+---------------------------------+
|                               1 |
+---------------------------------+

Keywords

WEEKDAY