Splunk Search

subtracting from "now(), or more specifically the time the query is run

samnew4598
Explorer

Hello all, I'm having trouble getting the correct difference in time when subtracting from the "now() " functions. Any help would be appreciated. Here is my sample query :

 

Where my start time stamp looks like: 2005-07-05T04:28:34.453494Z

 

 

index=main
| where status_1="open"
| eval start=strptime(create_time, "%Y-%m-%dT%H:%M:%S.%6QZ"
| eval current_time=now()
| eval diff=current_time-start
| fieldformat diff=tostring(diff, "duration")
| table _time, id_box, diff, start, end 

Labels (1)
0 Karma

venkatasri
SplunkTrust
SplunkTrust

Hi @samnew4598 

You query is fine, what you are getting assigned to diff is - 5852+05:56:10.546506 , here 5852 is number of days+HH:MM:SS.Milliseconds format. Are you expecting a different output format?

0 Karma
Get Updates on the Splunk Community!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...