Splunk Search

How to convert decimal time to a human readable format in a search?

vince2010091
Path Finder

Hello,

I've a decimal time in my logs like 1.51 that equal 1h30/1:30 or 4.3 equal 4h20/4:20

So i try to get a normal/human time with an eval:
eval TimeHour=floor(TimeBase) |
eval TimeMin=(TimeBase-TimeHour)*0.6 |
eval Time=TimeHour+TimeMin

For entry 1.5 i get 1.3 what is good but not perfect because i need 1:30

I've tried to convert it with strptime and strftime but i get 1:03 and not 1:30

eval TimeFormated=strftime(strptime(Time, "%H.%M"),"%H:%M")

I've didn't found any time format for base10 time or for minutes without leading zero

Thanks for help,

Regards,
Vincent

0 Karma
1 Solution

vince2010091
Path Finder

Hello, this isn't working but i added a round and now it's working fine

eval TimeMin=round((TimeBase-TimeHour)*0.6, 2) |

View solution in original post

0 Karma

vince2010091
Path Finder

Hello, this isn't working but i added a round and now it's working fine

eval TimeMin=round((TimeBase-TimeHour)*0.6, 2) |

0 Karma

richgalloway
SplunkTrust
SplunkTrust

You were this close:

eval TimeHour=floor(TimeBase) | eval TimeMin=(TimeBase-TimeHour)*60 | eval Time=TimeHour.":".TimeMin
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...