Splunk Search

How can I convert string of numbers to date format?

smcdonald20
Path Finder

I have a list of dates like below:

20170201
20171201
20171225

How can I convert this into a time value that i can sort oldest to youngest?

Tags (3)
0 Karma
1 Solution

somesoni2
Revered Legend

Try like this

your current search giving a field say "MyDate" | eval MyDateEpoch=strptime(MyDate,"%Y%m%d") | sort 0 MyDateEpoch

View solution in original post

0 Karma

smcdonald20
Path Finder

Thank you this worked!!

0 Karma

somesoni2
Revered Legend

Try like this

your current search giving a field say "MyDate" | eval MyDateEpoch=strptime(MyDate,"%Y%m%d") | sort 0 MyDateEpoch
0 Karma
Get Updates on the Splunk Community!

Why You Can't Miss .conf25: Unleashing the Power of Agentic AI with Splunk & Cisco

The Defining Technology Movement of Our Lifetime The advent of agentic AI is arguably the defining technology ...

Deep Dive into Federated Analytics: Unlocking the Full Power of Your Security Data

In today’s complex digital landscape, security teams face increasing pressure to protect sprawling data across ...

Your summer travels continue with new course releases

Summer in the Northern hemisphere is in full swing, and is often a time to travel and explore. If your summer ...