Splunk Search

Relative_time() and convert() Function

vasanthmss
Motivator

Hi Splunkers,

when i'm running first Search returns getting zero value where as second Search giving correct value. Explain me how its working,

Search 1:

|stats count | eval next_time=relative_time(now(),"-45y")

Search 2:

|stats count | eval next_time=relative_time(now(),"-45y")| convert ctime(*_time)
V
1 Solution

vasanthmss
Motivator

fdi01
Motivator

so see your command eval = next_time relative_time (now (), "- 45y") will provide no results that eventually you converted,
because if you run these commands get the same result
|stats count | eval next_time=relative_time(now(),"-45y")| convert ctime(_time)

or |stats count | convert ctime(
_time)

try the following different commands to understand the operation.
|stats count | convert ctime(count)
or
|stats count | convert timeformat="%H:%M:%S" ctime(count)
or
|stats count | eval next_time=count| convert ctime(_time) or |stats count | convert ctime(_time) next_time

0 Karma

kml_uvce
Builder

In first search its zero as its epoch time (start time) and when you are converting this epoch time in second search then its giving in date format
http://en.wikipedia.org/wiki/Unix_time

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...