dayofweek

description

Syntax

INT DAYOFWEEK(DATETIME date)

DAYOFWEEK函数返回日期的工作日索引值,即星期日为1,星期一为2,星期六为7

参数为Date或者Datetime类型或者可以cast为Date或者Datetime类型的数字

example

  1. mysql> select dayofweek('2019-06-25');
  2. +----------------------------------+
  3. | dayofweek('2019-06-25 00:00:00') |
  4. +----------------------------------+
  5. | 3 |
  6. +----------------------------------+
  7. mysql> select dayofweek(cast(20190625 as date));
  8. +-----------------------------------+
  9. | dayofweek(CAST(20190625 AS DATE)) |
  10. +-----------------------------------+
  11. | 3 |
  12. +-----------------------------------+

keywords

  1. DAYOFWEEK