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!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...