Getting Data In

How to convert HH:MM:SS.6Q time format in to Minutes

gravi
Explorer

Hi,

I am trying to convert Timestamp into Minutes and the result is not being displayed. I have the timestamp format as HH:MM:SS.SSSSSS and I want to convert to Minutes.

I have tried using |convert dur2sec(since) as TimeinSec | eval timeinMin=TimeinSec/60 but did not work.

could you please help?

0 Karma

woodcock
Esteemed Legend

Like this:

| makeresults 
| eval time="12:34:56.654321" 

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| rex field=time "(?:(?:(?<duration_hours>\d+):)?(?<duration_minutes>\d+):)?(?<duration_seconds>.+)$" 
| fillnull value=0 duration_hours duration_minutes 
| eval duration = duration_seconds + (60 * (duration_minutes + (60 * duration_hours))) 
| fieldformat duration = tostring(duration, "duration")
| fieldformat duration_in_minutes = duration / 60
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Use strptime to convert Timestamp into seconds then convert to minutes.

... | eval Minutes=strptime(Timestamp, "%H:%M:%S.%6N")/60
---
If this reply helps you, an upvote would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Improve Your Security Posture

Watch NowImprove Your Security PostureCustomers are at the center of everything we do at Splunk and security ...

Maximize the Value from Microsoft Defender with Splunk

 Watch NowJoin Splunk and Sens Consulting for this Security Edition Tech TalkWho should attend:  Security ...

This Week's Community Digest - Splunk Community Happenings [6.27.22]

Get the latest news and updates from the Splunk Community here! News From Splunk Answers ✍️ Splunk Answers is ...