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.

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 ...