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
Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...