now()
Returns the current system time.
Syntax
now()
Parameters
None
Description
The now() function returns the current system time at the moment of the call. The return type is timestamp.
Unlike the ago() function, now() recalculates the current time each time a record is evaluated.
Error codes
N/A
Usage examples
To prepare the WEB_APACHE_SAMPLE table used in these examples, refer to Preparing sample data.
-
Add the current time to each access log record.
table limit=5 WEB_APACHE_SAMPLE | eval current_time = now() | fields _time, current_time, src_ip, status -
Check whether the access log timestamp is before the current time.
table limit=5 WEB_APACHE_SAMPLE | eval result = (_time <= now()) | fields _time, result
Compatibility
The now() function has been available since before Sonar 4.0.