Dashboards & Visualizations

ISO 8061 string field- Is it better to do an extraction or conversion?

Mena
Explorer

Hello-

 

I am attempting to create a heat gauge off the average of two timestamp fields to determine average time an issue was worked. I'm running into issues as these fields are stored as strings in the ISO 8061 format.

I'd like to know if there's a good way to convert this string as simply as possible or to be able to extract certain portions of the string to be able to use a numeric value from the average calculations (ideally extract the MM:SS from the ISO string.)

 

Thanks!

Labels (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

strptime to parse date/time

| eval t1=strptime(time_1, "%FT%T")
| eval t2=strptime(time_2, "%FT%T")

%F parses date (YYYY-MM-DD) and %T parses time (HH:MM:SS)

then you have numbers and can do with them what you want.

if if you just want the MM:SS as seconds, use

| eval seconds = tonumber(substr(time_1, 15, 2)) * 60 + tonumber(substr(time_1, 18, 2))

 but that of course will ignore hours/days etc.

 

View solution in original post

bowesmana
SplunkTrust
SplunkTrust

strptime to parse date/time

| eval t1=strptime(time_1, "%FT%T")
| eval t2=strptime(time_2, "%FT%T")

%F parses date (YYYY-MM-DD) and %T parses time (HH:MM:SS)

then you have numbers and can do with them what you want.

if if you just want the MM:SS as seconds, use

| eval seconds = tonumber(substr(time_1, 15, 2)) * 60 + tonumber(substr(time_1, 18, 2))

 but that of course will ignore hours/days etc.

 

Mena
Explorer

Thank you so much! 

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...