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!

Good Sourcetype Naming

When it comes to getting data in, one of the earliest decisions made is what to use as a sourcetype. Often, ...

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Splunk App for Anomaly Detection End of Life Announcement

Q: What is happening to the Splunk App for Anomaly Detection?A: Splunk is officially announcing the ...