MariaDB SYSDATE() Function

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

Different from the NOW() function, the SYSDATE() function returns the exact system time when the function is executed, while the NOW() function returns the execution time of the statement, function, or stored procedure.

MariaDB SYSDATE() Syntax

This is the syntax of the MariaDB SYSDATE() function:

SYSDATE([precision])

Parameters

precision

Optional. The precision of fractional seconds. From 1 to 6.

Return value

MariaDB SYSDATE() returns the current datetime.

The SYSDATE() exact system time of execution of the function returned by the function, which may be different from the execution time of the statement.

If in a string context, SYSDATE() returns the current date in the YYYY-MM-DD HH:MM:SS format and it returns the current date in YYYYMMDDHHMMSS.uuuuuu format in a numeric context.

MariaDB SYSDATE() Examples

Example 1

The following statement shows the basic usage of the MariaDB SYSDATE() function:

SELECT
    SYSDATE(),
    SYSDATE(3),
    SYSDATE(6)\G

Output:

 SYSDATE(): 2023-01-12 11:00:10
SYSDATE(3): 2023-01-12 11:00:10.117
SYSDATE(6): 2023-01-12 11:00:10.117252

Example 2 - Numeric Context

When used in a numeric context, the resulting datetime is in the YYYYMMDDHHMMSS.uuuuuu format.

example:

SELECT
    SYSDATE(),
    SYSDATE() + 0,
    SYSDATE(6) + 0\G

Output:

     SYSDATE(): 2023-01-12 11:00:23
 SYSDATE() + 0: 20230112110023
SYSDATE(6) + 0: 20230112110023.205820

NOW()

Different from the NOW() function, the SYSDATE() function returns the exact system time when the function is executed, while the NOW() function returns the execution time of the statement, function, or stored procedure.

SELECT
    NOW(),
    SYSDATE(),
    SLEEP(10),
    NOW(),
    SYSDATE()\G

Output:

    NOW(): 2023-01-12 11:03:40
SYSDATE(): 2023-01-12 11:03:40
SLEEP(10): 0
    NOW(): 2023-01-12 11:03:40
SYSDATE(): 2023-01-12 11:03:50

Summarize

In MariaDB, SYSDATE() is a built-in function that returns the date and time when the function was executed.