How UTC_DATE() Works in MariaDB

In MariaDB, UTC_DATE() is a built-in date and time function that returns the current UTC date.

The result is returned in ‘YYYY-MM-DD’ or YYYYMMDD format, depending on whether the function is used in a string or numeric context.

UTC stands for Coordinated Universal Time, and is the world standard for regulating time.

Syntax

UTC_DATE() can be called with or without parentheses:

UTC_DATE
UTC_DATE()

Both return the same result.

Example

Here’s an example with parentheses:

SELECT UTC_DATE();

Result:

+------------+
| UTC_DATE() |
+------------+
| 2021-06-01 |
+------------+

Here it is without the parentheses:

SELECT UTC_DATE;

Result:

+------------+
| UTC_DATE   |
+------------+
| 2021-06-01 |
+------------+

Same result.

Numeric Dates

Using UTC_DATE() in a numeric context results in the date being returned in YYYYMMDD format.

Example:

SELECT UTC_DATE() + 0;

Result:

+----------------+
| UTC_DATE() + 0 |
+----------------+
|       20210601 |
+----------------+

Providing Arguments

The UTC_DATE() function doesn’t accept any arguments. Calling it with arguments results in an error:

SELECT UTC_DATE('1970-01-02');

Result:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''1970-01-02')' at line 1