Dashboards & Visualizations

combining date fields into a single field for charting.

rhuss
Engager

Is it possible to somehow combine the date_year, date_month and date_mday fields into a single date field?

I need to do this for charting purposes.

Tags (1)
0 Karma
1 Solution

ziegfried
Influencer

Yes:

... | strcat date_year "-" date_month "-" date_mday date_str

or

... | eval datestr=date_year."-".date_month."-".date_mday

or

... | eval datestr=strftime(_time, "%Y-%m-%d")

I would suggest to use the last one, as it is possible that the date_* fields are missing from the event.

View solution in original post

justinhart
Path Finder

Try:

| eval full_date = date_year." ".date_month." ".date_mday

You can format that in whatever way you want, the area between " " is the seperator.

This was found under the eval command reference here.

ziegfried
Influencer

Yes:

... | strcat date_year "-" date_month "-" date_mday date_str

or

... | eval datestr=date_year."-".date_month."-".date_mday

or

... | eval datestr=strftime(_time, "%Y-%m-%d")

I would suggest to use the last one, as it is possible that the date_* fields are missing from the event.

Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

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