Splunk Dev

issue with dropdown containing month and year value

k_harini
Communicator

I have to produce Jan-2017 Feb-2017 in the dropdown
search query |eval datetime = strftime(strptime(mydate,"%m/%d/%Y"),"%b-%Y")|dedup datetime|table datetime|sort - datetime

I get Feb and Jan which is sorted by alphabetical order. How to sort with month order. please help. Thanks!

Tags (1)
0 Karma
1 Solution

rjthibod
Champion

You probably have to use the numerical format for the month to sort, and then add the text version afterward. Try this.

<search query>
| eval datetime_num = strftime(strptime(mydate,"%m/%d/%Y"),"%m-%Y")
| dedup datetime_num
| table mydate datetime_num
| sort - datetime_num
| eval datetime = strftime(strptime(mydate,"%m/%d/%Y"),"%b-%Y")
| fields  datetime

View solution in original post

0 Karma

rjthibod
Champion

You probably have to use the numerical format for the month to sort, and then add the text version afterward. Try this.

<search query>
| eval datetime_num = strftime(strptime(mydate,"%m/%d/%Y"),"%m-%Y")
| dedup datetime_num
| table mydate datetime_num
| sort - datetime_num
| eval datetime = strftime(strptime(mydate,"%m/%d/%Y"),"%b-%Y")
| fields  datetime
0 Karma

k_harini
Communicator

Thanks a lot.. It worked!!

0 Karma
Get Updates on the Splunk Community!

New in Observability Cloud - Explicit Bucket Histograms

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

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...