Getting Data In

Difference between the 2 time fields

Real_captain
Path Finder

Hi 

Can someone please let me know how i can find the difference between the 2 fields Start-Time and End-Time in the below search. 

Format of time extracted by the query is : 

Start-Time = 2024-01-23T11:38:59.0000000Z

End-Time = 2024-01-23T11:39:03.0000000Z

Query : 

`macro_events_prod_srt_shareholders_esa` eocEnv = PRO * "MICROSOFT.DATAFACTORY" activityName = Merge_Disclosure_Request 741b5db8-da47-468b-b883-a06ef137519a
| eval Dreqid=case('category'="PipelineRuns",'properties.Parameters.DisclosureRequestId','category'="ActivityRuns",'properties.Input.storedProcedureParameters.DisclosureRequestId.value',1=1,"")
| eval end_time=case('end'="1601-01-01T00:00:00.0000000Z", "Still-Running",1=1,'end')
| table eocEnv , start , end_time , pipelineName , activityName, pipelineRunId,level , status , category , Type , Dreqid, properties.Error.errorCode , properties.Error.message
| rename Dreqid as "Disclosure request id" , eocEnv as "Environment" , EOC_ResourceGroup as " Resource_Group" , activityName as "Activity Name" , pipelineName as "Pipeline Name" , operationName as "Operation Name" , pipelineRunId as "Run_Id" , level as "Level" , status as "STATUS" , category as "Category" , start as "Start-Time" , end_time as "End-Time" , properties.Error.errorCode as "Error-Code" , properties.Error.message as "Error-Message"
| sort -"Start-Time"

 

Real_captain_0-1706019257853.png

 

 

 

 

0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Find the difference between two timestamps by converting each into epoch (integer) format using the strptime function and then subtract them.

| eval eStartTime=strptime('Start-Time', "%Y-%m-%dT%H:%M:%S.%6N%Z")
| eval eEndTime=strptime('End-Time', "%Y-%m-%dT%H:%M:%S.%6N%Z")

P.S.  Avoid using hyphens in field names as they can be mis-interpreted as the subtraction operator.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Find the difference between two timestamps by converting each into epoch (integer) format using the strptime function and then subtract them.

| eval eStartTime=strptime('Start-Time', "%Y-%m-%dT%H:%M:%S.%6N%Z")
| eval eEndTime=strptime('End-Time', "%Y-%m-%dT%H:%M:%S.%6N%Z")

P.S.  Avoid using hyphens in field names as they can be mis-interpreted as the subtraction operator.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...

Monitoring AI Agents with Splunk Observability Cloud

Let’s say I’m running a travel planning AI app in production. A user asks for three concise hotel options in ...