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!

Exciting News: The AppDynamics Community Joins Splunk!

Hello Splunkers,   I’d like to introduce myself—I’m Ryan, the former AppDynamics Community Manager, and I’m ...

The All New Performance Insights for Splunk

Splunk gives you amazing tools to analyze system data and make business-critical decisions, react to issues, ...

Good Sourcetype Naming

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