Languages
[Edit]
EN

MySQL - WEEKDAY() and DAYOFWEEK() differences

0 points
Created by:
Khloe-Kaiser
578

In this article, we would like to show you differences between WEEKDAY() and DAYOFWEEK() functions in MySQL.

WEEKDAY() function

The WEEKDAY() function counts days of the week from Monday and starts from 0.

Example:

0 = Monday 
1 = Tuesday
2 = Wednesday
3 = Thursday
4 = Friday
5 = Saturday
6 = Sunday

DAYOFWEEK() function

The DAYOFWEEK() function counts days of the week from Sunday and starts from 1.

Example:

1 = Sunday
2 = Monday 
3 = Tuesday
4 = Wednesday
5 = Thursday
6 = Friday
7 = Saturday

Practical example

In this example, we will select the current day of the week and display its number using WEEKDAY() and DAYOFWEEK() functions.

Query:

SELECT WEEKDAY(NOW()) 'weekday', DAYOFWEEK(NOW()) 'dayofweek';

Example result for Monday:

MySQL - WEEKDAY() and DAYOFWEEK() result for Monday
MySQL - WEEKDAY() and DAYOFWEEK() result for Monday

Alternative titles

  1. MySQL - WEEKDAY() vs DAYOFWEEK()
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

MySQL - dates

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join