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
Attention reader! Don’t stop learning now. Learn SQL for interviews using SQL Course by GeeksforGeeks.
WEEKDAY( date_value )
- Date Value –Date or datetime value from which to extract the weekday index.
It will return the time portion of a DateTime expression.
The curdate() function return the current system date. Today is Friday so it will return 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).
WEEKOFYEAR( date_value )
- date value –Date or DateTime value from which to extract the week of the year.
It returns the week of the year for a date value.