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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

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 GA in US-AWS!

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