Splunk Dev

sorting date/time

SoknySplunk
Loves-to-Learn Lots

Hi,
I have example of date/time as below

Mon 28 Dec 2015 06:26:19 PM ICT
Mon 26 May 2014 04:52:02 PM ICT
Fri 17 Feb 2017 04:01:59 PM ICT
Wed 28 Jun 2017 05:49:04 PM ICT
Wed 05 Oct 2016 06:46:30 PM ICT

I want to sort it by date, month year... in the correct order. could you please tell me how to do it.

Tags (1)
0 Karma

SoknySplunk
Loves-to-Learn Lots

It works well, thanks you

0 Karma

somesoni2
Revered Legend

You would have to convert the timestamp to epoch to sort it.

Option 1 (creating a new field to sort)

your current search giving above field with name say DateTime
| eval sortfield=strptime(DateTime,"%a %d %b %Y %H:%M:%S %p %Z") 
| sort sortfield| field - sortfield

Option 2 (using same field)

your current search giving above field with name say DateTime
| eval DateTime=strptime(DateTime,"%a %d %b %Y %H:%M:%S %p %Z") 
| sort DateTime| | eval DateTime=strftime(DateTime,"%a %d %b %Y %H:%M:%S %p %Z") 
0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...