MariaDB: WEEKOFYEAR Function
This MariaDB tutorial explains how to use the MariaDB WEEKOFYEAR function with syntax and examples.
Description
The MariaDB WEEKOFYEAR function returns week of the year for a date value.
Syntax
The syntax for the WEEKOFYEAR function in MariaDB is:
WEEKOFYEAR( date_value )
Parameters or Arguments
- date_value
- A date or datetime value from which to extract the week of the year.
Note
- The WEEKOFYEAR function returns the week of the year (a number from 1 to 53) given a date value.
- The WEEKOFYEAR function assumes that the first day of the week is Monday and the first week has more than 3 days.
- The WEEKOFYEAR function returns the same as the WEEK function with the syntax of WEEK(date_value,3).
Applies To
The WEEKOFYEAR function can be used in the following versions of MariaDB:
- MariaDB 10
Example
Let's look at some MariaDB WEEKOFYEAR function examples and explore how to use the WEEKOFYEAR function in MariaDB.
For example:
SELECT WEEKOFYEAR('2014-01-01'); Result: 1 SELECT WEEKOFYEAR('2014-05-19'); Result: 21 SELECT WEEKOFYEAR('2014-12-27'); Result: 52
This last WEEKOFYEAR example would display the week of the year for the current system date (current system date is returned by the CURDATE function).
SELECT WEEKOFYEAR(CURDATE());
Advertisements