Splunk Search

Splunk time difference showing as null

Das
Engager

I need to calculate time difference between start and end times. But I get the difference value as null. Not sure what I am missing.

Below is the sample query
| makeresults
| eval a="27 Mar 2025,02:14:11"
| eval b="27 Mar 2025,03:14:12"
| eval stime=strptime(a,"%d %b %Y,%H:%M:%S")
| eval etime=strptime(b,"%d %b %Y,%H:%M:%S")
| eval diff = eTime - sTime
| table a b stime etime diff

I get the below result with diff value empty:

a b stime etime diff

27 Mar 2025,02:14:1127 Mar 2025,03:14:121743041651.0000001743045252.000000 

 

Please help in identifying where I am going wrong

Labels (1)
Tags (1)
0 Karma
1 Solution

yuanliu
SplunkTrust
SplunkTrust

Please help in identifying where I am going wrong

How about spelling error?

| makeresults
| eval a="27 Mar 2025,02:14:11"
| eval b="27 Mar 2025,03:14:12"
| eval stime=strptime(a,"%d %b %Y,%H:%M:%S")
| eval etime=strptime(b,"%d %b %Y,%H:%M:%S")
| eval diff = etime - stime
| table a b stime etime diff
abstimeetimediff
27 Mar 2025,02:14:1127 Mar 2025,03:14:121743066851.0000001743070452.0000003601.000000

View solution in original post

0 Karma

yuanliu
SplunkTrust
SplunkTrust

Please help in identifying where I am going wrong

How about spelling error?

| makeresults
| eval a="27 Mar 2025,02:14:11"
| eval b="27 Mar 2025,03:14:12"
| eval stime=strptime(a,"%d %b %Y,%H:%M:%S")
| eval etime=strptime(b,"%d %b %Y,%H:%M:%S")
| eval diff = etime - stime
| table a b stime etime diff
abstimeetimediff
27 Mar 2025,02:14:1127 Mar 2025,03:14:121743066851.0000001743070452.0000003601.000000
0 Karma

Das
Engager

Thanks for noticing it. 
Its my bad. its working as expected.

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...