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!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...