SYSDATE()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Enterprise Server
Topics on this page:
Overview
Returns the current system date and time.
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, theSYSDATE()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 contextSYSDATE()returns a numeric YYYYMMDDhhmmss value when used in numeric contextSYSDATE()accepts an optional argument in the range of0to6that specifies the number of digits of fractional seconds to append to the returned value following a decimal point. The default of0appends no digits and no decimal point.
PARAMETERS
| 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_
SELECT SYSDATE(7);
ERROR 1426 (42000): Too big precision 7 specified for 'sysdate'. Maximum is 6
CHANGE HISTORY
EXTERNAL REFERENCES
Additional information on this topic may be found in the MariaDB Public Knowledge Base.
