Splunk Search

How to shorten the numeric values for a field to only 2 decimals?

SecurityIsMyMid
Explorer

Here is my search fields + host,lastTime,dayDiff | eval c_time=strftime(log_time,"%m/%d/%y %H:%M:%S")
I'm trying to shorten daydiff to only 2 decimals. I've tried all the other answers and nothing seems to work.

0 Karma

sundareshr
Legend

Like this eval daydiff=round(daydiff, 2) before you do the strftime

SecurityIsMyMid
Explorer

My whole search is:

| `host_eventcount(30,2)` | search is_expected=true | `ctime(lastTime)`  | fields + host,lastTime,dayDiff  |rename host AS "Hostname", lastTime AS "Last Time Seen" , dayDiff AS "Days Not Seen" | eval c_time=strftime(log_time,"%m/%d/%y %H:%M:%S") 

Anyway to make this more efficient?

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!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...