WEEKDAY Function and WEEKOFYEAR Function in MariaDB
1. WEEKDAY Function :
In MariaDB, The Weekday Function returns the weekday index for a date. In this function, the first parameter will be the Date value. This function returns the weekday index for a date. In WEEKDAY function returns the index value of the weekday given a date value. It works opposite to the DAYNAME function. And index values are as follows.
0=Monday,
1=Tuesday,
2=Wednesday,
3=Thursday,
4=Friday,
5=Saturday,
6=Sunday
Syntax :
WEEKDAY( date_value )
Parameter :
- Date Value –Date or datetime value from which to extract the weekday index.
Return :
It will return the time portion of a DateTime expression.
Example-1 :
SELECT WEEKDAY('2014-05-20');
Output :
1
Example-2 :
The curdate() function return the current system date. Today is Friday so it will return 5.
SELECT WEEKDAY(CURDATE());
Output :
5
2. WEEKOFYEAR function :
In MariaDB, WEEKOFYEAR function is used to return the week of the year for a date value. In this function, the first parameter will be the date value. This function returns the week of the year (a number from 1 to 53) given a date value. This function assumes that the first day of the week is Monday and the first week has more than 3 days. WEEKOFYEAR function returns the same as the WEEK function with the syntax of WEEK(date_value,3).
Syntax :
WEEKOFYEAR( date_value )
Parameters :
- date value –Date or DateTime value from which to extract the week of the year.
Return :
It returns the week of the year for a date value.
Example-1 :
SELECT WEEKOFYEAR('2020-01-01');
Output :
1
Last Updated :
16 Dec, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...