MySQL DAYOFWEEK() Function

MySQL | DAYOFWEEK() Function: Learn about the DAYOFWEEK() function, how it works, its usages, syntax, and examples.
Submitted by Apurva Mathur, on October 05, 2022

DAYOFWEEK() Function

The DAYOFWEEK() function gives you the day of a week in the numerical form of any particular date.

DAYOFWEEK() Syntax

SELECT DAYOFWEEK('date');

DAYOFWEEK() Parameter(s)

  • date: It accepts a date for which you have to get the weekday index.

DAYOFWEEK() Return Value

As a result, it will return you the day of the week in the numerical form of the date you have provided.

MySQL DAYOFWEEK() Function Example 1

SELECT DAYOFWEEK('2011-01-17');
Example 1: MySQL DAYOFWEEK() Function

MySQL DAYOFWEEK() Function Example 2

SELECT DAYOFWEEK('2022-10-20');
Example 2: MySQL DAYOFWEEK() Function

MySQL DAYOFWEEK() Function Example 3

SELECT DAYOFWEEK('2022-19-31');
Example 3: MySQL DAYOFWEEK() Function

If the date is not valid then in such case it will return you the NULL.




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.