Splunk Search

Is there a way to remove seconds from a table?

jrevolorio
Explorer

I'm trying to create a report where it shows the date and time; however, when it comes to time I just want it to display the hour and minutes, not the seconds. Is there a way to do that?

Tags (4)
0 Karma
1 Solution

Grumpalot
Communicator

@jrevolorio try adding this pipe into your search your search | eval time=strftime(_time, "%H:%M") | your report

What we are doing is taking the _time field and stripping out the Hour and Minute only. If you have another field you are pulling time from you can replace _time for that field. When you create your output you will then use the time field instead.

View solution in original post

DalJeanis
Legend

You can format it, the way that @richgalloway and @Grumpalot said, or you can actually change the _time to eliminate the seconds like this -

| eval _time = 60*floor(_time/60)

Under the above, the standard output for _time should hide the seconds.

richgalloway
SplunkTrust
SplunkTrust

Use the fieldformat command. Something like this:

... | fieldformat myField=strftime(myField, "%Y-%m-%d %H:%M")
---
If this reply helps you, Karma would be appreciated.
0 Karma

Grumpalot
Communicator

@jrevolorio try adding this pipe into your search your search | eval time=strftime(_time, "%H:%M") | your report

What we are doing is taking the _time field and stripping out the Hour and Minute only. If you have another field you are pulling time from you can replace _time for that field. When you create your output you will then use the time field instead.

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!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...