<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: What is the best way to calculate date and time span? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-calculate-date-and-time-span/m-p/303164#M91219</link>
    <description>&lt;P&gt;Why not convert your dates in epoch time (using eval or convert  and mktime)&lt;BR /&gt;
then convert your SLA in seconds, and add/subtract if from your dates&lt;BR /&gt;
and at the end, convert back to a date (using eval/convert and ctime)&lt;/P&gt;</description>
    <pubDate>Thu, 22 Feb 2018 01:42:18 GMT</pubDate>
    <dc:creator>yannK</dc:creator>
    <dc:date>2018-02-22T01:42:18Z</dc:date>
    <item>
      <title>What is the best way to calculate date and time span?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-calculate-date-and-time-span/m-p/303163#M91218</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;
What I am trying to do is calulate dates and span. &lt;BR /&gt;
So I have a date called "Date Due" and a field "SLA". What I am trying to do is take "Date Due" and add "SLA" compare to the current date and give how many days past it currently is.&lt;/P&gt;

&lt;P&gt;Currently Im using this but the results arent spot on&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=fp_dev_tsv "BO Type"="assessments"  | rename "BO ID" as id| convert timeformat="%Y-%m-%d %H:%M:%S.%6N"  mktime("Step Date Started") AS starttime  mktime("Step Date Completed") AS endtime mktime("Step Due Date") AS cumulativeDueDate mktime("Step Actual Due Date") AS actualDueDate

|eval dueDateRange=mvrange(actualDueDate,now(),86400)
|convert ctime(dueDateRange) timeformat="%+" 
| eval pastDueDays =mvcount(mvfilter(NOT match(dueDateRange,"(Sun|Sat).*")))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this doesnt take into account the SLA field just counts the days from the actualDueDate until now in days. Its correct BUT I need to add in SLA and then compare&lt;BR /&gt;
Heres a sample table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Name         Past Due Step Name       Past Due Step Due Date     SLA for Past Due Step

General Name    Info 1  2018-02-01 20:38:10.154000  3

Genberal Name   Info 2  2018-02-10 20:38:10.154000  10

General Name    Info 3  2018-03-08 20:38:10.154000  5

General Name    Info 4  2018-03-15 20:38:10.154000  5

General Name    Info 5  2018-03-22 20:38:10.154000  5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So what I need to do is check each steps due date, add SLA and then compare to todays date.&lt;BR /&gt;
Any idea how I can achieve this?&lt;/P&gt;

&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 17:14:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-calculate-date-and-time-span/m-p/303163#M91218</guid>
      <dc:creator>tkwaller_2</dc:creator>
      <dc:date>2018-02-21T17:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to calculate date and time span?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-calculate-date-and-time-span/m-p/303164#M91219</link>
      <description>&lt;P&gt;Why not convert your dates in epoch time (using eval or convert  and mktime)&lt;BR /&gt;
then convert your SLA in seconds, and add/subtract if from your dates&lt;BR /&gt;
and at the end, convert back to a date (using eval/convert and ctime)&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 01:42:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-calculate-date-and-time-span/m-p/303164#M91219</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2018-02-22T01:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to calculate date and time span?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-calculate-date-and-time-span/m-p/303165#M91220</link>
      <description>&lt;P&gt;yep, thats exactly what I did, thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 15:11:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-calculate-date-and-time-span/m-p/303165#M91220</guid>
      <dc:creator>tkwaller_2</dc:creator>
      <dc:date>2018-02-26T15:11:57Z</dc:date>
    </item>
  </channel>
</rss>

