Splunk Search

How to find the difference between two dates/times and add a new column to a table to show the difference?

harish_ka
Communicator

i have a query as below...

search 1|join type=left [search2]

the query returns the following fields...

place | ABC |XYZ |dateofSearch1|PQR |dateofSearch2

aaaa | acc | det | 2014/1/2 01:48:01 CST | eee | 2014/11/27 01:48:01 CST

i want to find the difference of date/time of dateofSearch1 and dateofSearch2... and add a new column to show the difference..

Can anyone help me to do this....

Tags (3)
1 Solution

kml_uvce
Builder

try this

search 1 | join type=left [search2] | eval diffTime=dateofSearch2 - dateofSearch1

View solution in original post

kml_uvce
Builder

try this

search 1 | join type=left [search2] | eval diffTime=dateofSearch2 - dateofSearch1

harish_ka
Communicator

Worked with few modifications in my query...

eval diffTime=strptime(dateofSearch2, "%Y/%m/%d %H:%M:%S")-strptime(dateofSearch1, "%Y/%m/%d %H:%M:%S")
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 ...