How YEARWEEK() Works in MariaDB

In MariaDB, YEARWEEK() is a built-in date and time function that returns the year and week for a given date.

It accepts two arguments; the date you want to extract the year and week from, and an optional mode argument to specify the mode to use in the result.

It returns the week as a number in the range 0 to 53 or 1 to 53, depending on the mode being used. Also, the year in the result may be different from the year in the date argument for the first and the last week of the year.

Continue reading

How HOUR() Works in MariaDB

In MariaDB, HOUR() is a built-in date and time function that returns the hour from a given time expression.

It accepts one argument, which is the time you want to extract the hour from.

For time-of-day values, it returns the hour as a number in the range 0 to 23. However, the range of TIME values can be much larger, and therefore, the returned value can be much higher than 23.

The return value is always positive, even if a negative time is provided.

Continue reading