Splunk Search

How to comparing 2 date fields and create a third with the difference

ajdyer2000
Path Finder

Event_Reported_Time Comment_Date Diff
7/21/2016 7/22/2016 1
7/24/2016 7/29/2016 5
8/16/2016 8/25/2016 9

Tags (2)
0 Karma

sbbadri
Motivator

| makeresults | eval Event_Reported_Time="7/21/2016" | eval Comment_Date="7/22/2016" | eval Event_Reported_Time = strptime(Event_Reported_Time,"%m/%d/%Y") | eval Comment_Date = strptime(Comment_Date,"%m/%d/%Y") | eval diff_time = Comment_Date - Event_Reported_Time | eval diff_days = diff_time / 86400

0 Karma

woodcock
Esteemed Legend

Like this:

... | foreach * [eval <<FIELD>>_Epoch = strptime(<<FIELD>>, "%m/%d/%Y")]
| eval Diff = (Comment_Date_Epoch - Event_Reported_Time_Epoch) / (60*60*24)
0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

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