Splunk Search

Calculate Date Diff - two different events in the two different sourcetypes

erick_costa
Path Finder
sourcetype=teste1
============================
code, datahora
_________________
1, 2013-05-07 15:51:13.772

sourcetype=teste2
============================
code, datahora
_________________
1, 2013-05-07 15:55:13.060
Tags (2)
0 Karma

aholzer
Motivator

Perform an eval "strptime" on both dates, or a convert with timeformat, then simply use another eval to do the subtraction.

Something like this from this answer (http://splunk-base.splunk.com/answers/10021/delta-between-two-date-data-fields):
...| convert timeformat='%m-%d-%Y %T' mktime(starttime) mktime(endtime) | eval duration=(endtime-starttime)/86400

There are quite a few different ways to do it. If you search for "splunk difference between two dates", or "splunk subtracting two dates" or similar, you should get quite a few answers to your question.

erick_costa
Path Finder

How to calculate datediff?

0 Karma

Ayn
Legend

Yes? Did you have a question?

Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...