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!

Splunk Lantern | Spotlight on Security: Adoption Motions, War Stories, and More

Splunk Lantern is a customer success center that provides advice from Splunk experts on valuable data ...

Splunk Cloud | Empowering Splunk Administrators with Admin Config Service (ACS)

Greetings, Splunk Cloud Admins and Splunk enthusiasts! The Admin Configuration Service (ACS) team is excited ...

Tech Talk | One Log to Rule Them All

One log to rule them all: how you can centralize your troubleshooting with Splunk logs We know how important ...