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 Registration is OPEN!

Ready. Set. Splunk! Your favorite Splunk user event is back and better than ever. Get ready for more technical ...

Detecting Cross-Channel Fraud with Splunk

This article is the final installment in our three-part series exploring fraud detection techniques using ...

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...