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!

Data Preparation Made Easy: SPL2 for Edge Processor

By now, you may have heard the exciting news that Edge Processor, the easy-to-use Splunk data preparation tool ...

Introducing Edge Processor: Next Gen Data Transformation

We get it - not only can it take a lot of time, money and resources to get data into Splunk, but it also takes ...

Tips & Tricks When Using Ingest Actions

Tune in to learn about:Large scale architecture when using Ingest ActionsRegEx performance considerations ...