MySQL Tutorial/Date Time Functions/WEEKDAY

Материал из SQL эксперт
Перейти к: навигация, поиск

SELECT WEEKDAY("1997-11-05");

mysql>
mysql> SELECT WEEKDAY("1997-11-05");
+-----------------------+
| WEEKDAY("1997-11-05") |
+-----------------------+
|                     2 |
+-----------------------+
1 row in set (0.00 sec)
mysql>


WEEKDAY(date) different and returns the weekday index for the given date(0=Monday, 1=Tuesday, 2=Wednesday, and so on).

mysql>
mysql> SELECT DAYOFWEEK("0-2-1");
+--------------------+
| DAYOFWEEK("0-2-1") |
+--------------------+
|                  3 |
+--------------------+
1 row in set (0.00 sec)
mysql>


WEEKDAY(date) returns the weekday index for date (0 = Monday, 1 = Tuesday, ... 6 = Sunday).

mysql>
mysql> SELECT WEEKDAY("1998-02-03 22:23:00");
+--------------------------------+
| WEEKDAY("1998-02-03 22:23:00") |
+--------------------------------+
|                              1 |
+--------------------------------+
1 row in set (0.00 sec)
mysql>