Splunk Search

How do you convert a month number to a month string?

sph0lt0n
Engager

Some timestamps use month numbers like "11" rather than strings like "Nov".

I'm using this eval to make the conversion:

| eval month=if(isnotnull(MM),if(MM="01","Jan",if(MM="02","Feb",if(MM="03","Mar",if(MM="04","Apr",if(MM="05","May",if(MM="06","Jun",if(MM="07","Jul",if(MM="08","Aug",if(MM="09","Sep",if(MM="10","Oct",if(MM="11","Nov",if(MM="12","Dec","INV")))))))))))),MM)

Is there a better way?

Tags (1)
0 Karma

sduff_splunk
Splunk Employee
Splunk Employee

If you have a timestamp you can work with

| eval month=strftime(_time,"%b")

Otherwise, you could tidy up the if statement by using a case statement instead

| eval month=case(
MM="01","Jan",
MM="02","Feb",
MM="03","Mar",
MM="04","Apr",
MM="05","May",
MM="06","Jun",
MM="07","Jul",
MM="08","Aug",
MM="09","Sep",
MM="10","Oct",
MM="11","Nov",
MM="12","Dec",
1=1, "INV")
0 Karma
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...