Splunk Search

formatting _time field into a YYYY-MM-DD field

HattrickNZ
Motivator

This search is ok
... | stats max(fieldname1) as fn1 by _time

but I want to control the format of the _time field to be format to be YYYY-MM-DD

How can I do this?

I know i can do ... | timechart span=d max(fieldname1) as fn1 but i am looking for another way as it relates to something I am working on and the timechart option won't work.

I am think something like

... | eval time_field=(_time,"YYYY-MM-DD")| stats max(fieldname1) as fn1 by time_field

Can this be done?

Tags (4)
0 Karma

jtrucks
Splunk Employee
Splunk Employee

Use convert:

... | convert timeformat="%Y-%m-%d" ctime(_time) AS ctime | ...

You can use whatever ... AS yourfield you want, of course.

--
Jesse Trucks
Minister of Magic

stephane_cyrill
Builder

try this:
... | eval time_field=strptime
(_time,"%Y-%m-%d")|
stats max(fieldname1)
as fn1 by time_field

HattrickNZ
Motivator
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...