Reporting

extract month from a date field

kajolsharma
Path Finder

Hi, I hav a "Planned Start date" Field through which I am trying to extract month in the format (e.g January).Can somebody suggest? Below is what i have tried 

kajolsharma_1-1630936881672.png

index="tier1" sourcetype="csv"| stats latest("Planned Start Date") AS Time| eval monthdisplay=strftime(strptime('Planned Start Date',"%m-%d-%Y"),"%B")|fields Time monthdisplay

 

 

Labels (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @kajolsharma,

There two errors:

  • The field name to use is "Time",
  • date form is wrong.

please try something like this:

index="tier1" sourcetype="csv"
| stats latest("Planned Start Date") AS Time
| eval monthdisplay=strftime(strptime(Time,"%m/%d/%Y"),"%B")
| fields Time monthdisplay

Eventually use double quotes also in the strptime function and, possibly, avoid spaces in the field names!

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...