SYSDATE()

Returns the current system date and time.

See also: Functions in 10.6 ES, in 10.6 CS, in 10.5 ES, in 10.5 CS, in 10.4 ES, in 10.4 CS, in 10.3 ES, in 10.3 CS, in 10.2 ES, and in 10.2 CS

USAGE

SYSDATE([fsp])

DETAILS

  • SYSDATE() is a date-time function that returns the current system date and time.

  • SYSDATE() returns a fresh date-time value for every invocation of the function, even when the function is invoked multiple times within the same statement or when the statement is re-executed on a replica using statement-based replication. When this behavior is problematic, the SYSDATE() can be configured to work the same as the NOW() function by setting the --sysdate-is-now option.

  • SYSDATE() returns a string in the format 'YYYY-MM-DD hh:mm:ss' when used in string context

  • SYSDATE() returns a numeric YYYYMMDDhhmmss value when used in numeric context

  • SYSDATE() accepts an optional argument in the range of 0 to 6 that specifies the number of digits of fractional seconds to append to the returned value following a decimal point. The default of 0 appends no digits and no decimal point.

PARAMETERS

fsp

The value expression for the fractional seconds precision. The value expression is evaluated for each row that qualifies.

EXAMPLES

SELECT SYSDATE();
+---------------------+
| SYSDATE()           |
+---------------------+
| 2021-07-06 18:34:39 |
+---------------------+
SELECT SYSDATE(6), SYSDATE(6), SYSDATE(6);
+----------------------------+----------------------------+----------------------------+
| SYSDATE(6)                 | SYSDATE(6)                 | SYSDATE(6)                 |
+----------------------------+----------------------------+----------------------------+
| 2021-07-06 18:34:39.219218 | 2021-07-06 18:34:39.219235 | 2021-07-06 18:34:39.219236 |
+----------------------------+----------------------------+----------------------------+

ERROR HANDLING

Too big precision

The SYSDATE() function accepts an optional argument for fractional seconds precision, which should be in the range 0 to 6. When a value greater than 6 is provided, the function raises an error with the ER_TOO_BIG_PRECISION error code:

SELECT SYSDATE(7);
ERROR 1426 (42000): Too big precision 7 specified for 'sysdate'. Maximum is 6

CHANGE HISTORY

Release Series

History

10.6 Enterprise

  • Present starting in MariaDB Enterprise Server 10.6.4-1.

10.6 Community

  • Present starting in MariaDB Community Server 10.6.0.

10.5 Enterprise

  • Present starting in MariaDB Enterprise Server 10.5.3-1.

10.5 Community

  • Present starting in MariaDB Community Server 10.5.0.

10.4 Enterprise

  • Present starting in MariaDB Enterprise Server 10.4.6-1.

10.4 Community

  • Present starting in MariaDB Community Server 10.4.0.

10.3 Enterprise

  • Present starting in MariaDB Enterprise Server 10.3.16-1.

10.3 Community

  • Present starting in MariaDB Community Server 10.3.0.

10.2 Enterprise

  • Present starting in MariaDB Enterprise Server 10.2.25-1.

10.2 Community

  • Present starting in MariaDB Community Server 10.2.0.

EXTERNAL REFERENCES