Splunk Search

Date Format

JoeSco27
Communicator

I have a field called DATE and it is returning values yyyy-mm-dd HH:MM:SS. I am trying to chop off the hours, min, seconds so I only have yyyy-mm-dd. I have tried to use the convert command but I would rather not have to convert it to epoch time and then convert it back. Is there an easier way to go about this?

Thank you in advance

Tags (2)
0 Karma

asimagu
Builder

the most efficient way is to set up TIME_FORMAT in props.conf . That will do the magic at indexing time

0 Karma

JoeSco27
Communicator

| eval n=strptime(DATE, "%Y-%m-%d") | convert timeformat="%Y %m %d" ctime(n) AS c_time | chart count by c_time

this gave me the count for each day i requested, thank you for the help

0 Karma

JSapienza
Contributor

If Splunk is not already parsing out this field , you can use something like such:

...|rex field=DATE mode=sed "/s/\d{2}:\d{2}:\d{2}//g"
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...