Splunk Search

get latest time stamp from two timestamps

Dassari
New Member

HI I have two time stamps like "2017-01-30T19:22:39Z" "2017-01-29T19:17:33Z"
From the above two timestamps I wan to get latest timestamp i.e 2017-01-30T19:22:39Z, please help me

Tags (1)
0 Karma

varad_joshi
Communicator

How about this.
Convert them in epoch time and then do the selection with an IF clause. Select whichever is larger.

Just shared the logic, see if that works for you.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try this.

... | eval LatestTS = if(strptime(TS1,"%Y-%m-%dT%H:%M:%S%Z")>strptime(TS2,"%Y-%m-%dT%H:%M:%S%Z"), TS1, TS2) | ...
---
If this reply helps you, Karma would be appreciated.
0 Karma

varad_joshi
Communicator

haha you beat me with few seconds there, and you posted the exact query. Yes, this should work for the OP.

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...