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!

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!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...