โญ Support Time.now: Join our Premium Plan for an ad-free experience! โญ Support Us: Go Premium Ad-Free!

Week numbers in MariaDB

To get the current ISO 8601 week number in MariaDB, use the following code snippet:

SELECT WEEK(NOW(), 3);

* Ensure your system or application regional settings are set to follow ISO 8601 standards (weeks start on Monday) if the output varies.

Step-by-Step Instructions

  1. Run: SELECT WEEK(NOW(), 3);
  2. Mode 3 gives ISO 8601 numbering (Monday start, first 4-day week).
  3. YEARWEEK(NOW(), 3) returns the ISO year and week combined for safe sorting.

Good to Know

MariaDB behaves exactly like MySQL here: without the explicit mode argument you get US-style numbering, which disagrees with ISO in most years around January 1.