NOW
Description
The now
function is a non-deterministic function used to return the current timestamp. During the execution of a query, no matter how many times the now
function is called, the returned timestamp is the same, fixed from the moment the query starts.
Syntax
Parameters
None
Return Result Type
timestamp_ltz
Usage Example
The following is a simple example of using the now
function:
After executing the above SQL statement, the result will be similar to the following, with the specific time varying according to the actual time of the query execution:
More Examples
- Use the current timestamp as the record creation time when inserting data:
- When selecting data, filter out records created in the past 24 hours:
- Compare the current time with the last update time of the record to determine if the record has changed within the last hour:
By the above example, you can better understand the usage scenarios of the CURRENT_TIMESTAMP
function in practical applications.