Splunk Search

Difference between two dates

kanalasreekanth
New Member

I have two fileds as below, now i would like to get difference date i.e Mydat-previousdate

Mydate | previousdate
2016-10-18T03:58:46 |152 day(s), 16 hour(s), 58 minute(s), 49 second(s)

Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Something like this should get you started.

... | rex field=previousdate "(?<days>\d+) day\(s\), (?<hrs>\d+) hour\(s\), (?<min>\d+) minute\(s\), (?<secs>\d+) second\(s\)" | fillnull value=0 | eval diff = strptime(Mydate,"%Y-%m-%dT%H:%M:%S") - (days * 86400) - (hrs * 3600) - (min * 60) - secs | eval diffDate = strftime(diff,"%Y-%m-%dT%H:%M:%S") | ...
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...