Timestamp Functions
CURRENT_TIMESTAMP
Overview
The CURRENT_TIMESTAMP()
returns the current timestamp value representing the date and time the query was executed.
Note that the time returned by this function is the time when the query was executed.
Syntax
The precision
is used to set the number of digits in the fractional seconds precision in the second field.
If you omit the precision
, the CURRENT_TIMESTAMP()
function will return a current timestamp that includes the complete fractional seconds precision.
The maximum precision value that you can input is 6.
Examples
#Case 1: Current timestamp
The following example shows how to get the current date and time with a CURRENT_TIMESTAMP()
function:
The final result will display the current date and time in your timezone:
#Case 2: Current timestamp with precision
Let’s assume we want to get the current timestamp but with a 2-fractional seconds precision:
The function will return the current date and time with 2 digits after seconds: