Getting Data In

How do you build a chart from two date fields?

gcescatto
New Member

On my current data I have two date fields: CommencementDate and CompletitionDate.
I would like to build a chart where the timestamp would be CompletitionDate - CommencementDate. For that, I created the query below:

| eval InspectionDate=strptime(CompletionDate, “%Y-%m-%dT%H:%M:%S”)-strptime(CommencementDate, “%Y-%m-%dT%H:%M:%S”) |

The date format is: 2015-01-27T06:00:00

Could someone please advise?

Tags (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

You almost had it. Once you subtract the respective epoch times you just need to put the result back into text form.

... | eval InspectionDate=strftime(strptime(CompletionDate, “%Y-%m-%dT%H:%M:%S”)-strptime(CommencementDate, “%Y-%m-%dT%H:%M:%S”), "%Y-%m-%dT%H:%M:%S") | ...
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

You almost had it. Once you subtract the respective epoch times you just need to put the result back into text form.

... | eval InspectionDate=strftime(strptime(CompletionDate, “%Y-%m-%dT%H:%M:%S”)-strptime(CommencementDate, “%Y-%m-%dT%H:%M:%S”), "%Y-%m-%dT%H:%M:%S") | ...
---
If this reply helps you, Karma would be appreciated.

gcescatto
New Member

Hi richgalloway (:

I did try using the updated query you provided me, but I’m still not getting any results for InspectionTime... any other inputs? 🙂

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...