<?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: need help in finding the time differece btween two fields when thid field value is null in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/need-help-in-finding-the-time-differece-btween-two-fields-when/m-p/447732#M177002</link>
    <description>&lt;P&gt;Try this: &lt;CODE&gt;|eval now_sla_diff = if(isnull(FILE_ARRIVALTIME ), (now_time - sla_time),null())&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Feb 2019 10:20:55 GMT</pubDate>
    <dc:creator>chrisyounger</dc:creator>
    <dc:date>2019-02-07T10:20:55Z</dc:date>
    <item>
      <title>need help in finding the time differece btween two fields when thid field value is null</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-in-finding-the-time-differece-btween-two-fields-when/m-p/447731#M177001</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;

&lt;P&gt;Can you please help me with the solution for the following usecase.&lt;/P&gt;

&lt;P&gt;i have three fields named as follows, i want to create another field  named with &lt;STRONG&gt;now_sla_diff&lt;/STRONG&gt;  where we should calculate the difference between &lt;STRONG&gt;now_time&lt;/STRONG&gt; and &lt;STRONG&gt;sla_time&lt;/STRONG&gt; when the &lt;STRONG&gt;FILE_ARRIVALTIME&lt;/STRONG&gt; value is null.&lt;/P&gt;

&lt;P&gt;sla_time                     FILE_ARRIVALTIME        now_time&lt;/P&gt;

&lt;P&gt;2/6/2019 23:55     2/6/2019 23:02           2/7/2019 3:48&lt;BR /&gt;
2/6/2019 23:55                                       2/7/2019 3:48&lt;/P&gt;

&lt;P&gt;P S: i cant makresults command in my query as i m already joining two queries.&lt;/P&gt;

&lt;P&gt;Thank you in advance.&lt;/P&gt;

&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/156785"&gt;@vnravikumar&lt;/a&gt; &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/199197"&gt;@jkat54&lt;/a&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:06:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-in-finding-the-time-differece-btween-two-fields-when/m-p/447731#M177001</guid>
      <dc:creator>pench2k19</dc:creator>
      <dc:date>2020-09-29T23:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: need help in finding the time differece btween two fields when thid field value is null</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-in-finding-the-time-differece-btween-two-fields-when/m-p/447732#M177002</link>
      <description>&lt;P&gt;Try this: &lt;CODE&gt;|eval now_sla_diff = if(isnull(FILE_ARRIVALTIME ), (now_time - sla_time),null())&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 10:20:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-in-finding-the-time-differece-btween-two-fields-when/m-p/447732#M177002</guid>
      <dc:creator>chrisyounger</dc:creator>
      <dc:date>2019-02-07T10:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: need help in finding the time differece btween two fields when thid field value is null</title>
      <link>https://community.splunk.com/t5/Splunk-Search/need-help-in-finding-the-time-differece-btween-two-fields-when/m-p/447733#M177003</link>
      <description>&lt;P&gt;thanks for the quick response mate @chrisyoungerjds ...it works....the following is my udapted queery...somehow its not printing negative values in the time difference values. can you please help&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup SLA.csv  |rex field=SOR_TDQ_FAIL_SLA_THRESHOLD "(?P.*)\,(?.*)" | eval sla_time = case(date="BUS_DT+1",strftime(now(),"%Y-%m-%d").",".time,date="BUS_DT+0",strftime(relative_time(time(), "-d"),"%Y-%m-%d".",".time))|eval sla_time=replace (sla_time,","," ") |eval sla_time=sla_time + ":00" |table SOR_NAME FEED_NAME sla_time |dedup SOR_NAME FEED_NAME |join type=outer SOR_NAME FEED_NAME [search index=bp_ede_om_mbda source="XXXX.log" |rex "info\s:\s\+{4}\sSTARTED\s\+{4}\sJob run_ingest_(?\w+)_(?\d+-\d+-\d+-\d+-\d+-\d+)_"|rex field=Datafeed_name "^(?\w{2,5})_(?\w+)$" | eval FILE_ARRIVALTIME = strftime(strptime(start_time,"%Y-%m-%d-%H-%M-%S") ,"%Y-%m-%d %H:%M:%S") | eval FILE_ARRIVALTIME_epoch=strptime(FILE_ARRIVALTIME,"%Y-%m-%d %H:%M:%S") |fields SOR_NAME FEED_NAME FILE_ARRIVALTIME FILE_ARRIVALTIME_epoch] |eval now_time=strftime(now(), "%Y-%m-%d %H:%M:%S") | eval now_time_epoch = strptime(now_time,"%Y-%m-%d %H:%M:%S")| eval sla_time_epoch = strptime(sla_time,"%Y-%m-%d %H:%M:%S")| eval time_diff = tostring((FILE_ARRIVALTIME_epoch-sla_time_epoch), "duration")| eval arr_sla_diff=replace(time_diff,"(\d*)\+*(\d+):(\d+):(\d+)","\1 day(s) \2 hour(s) \3 minute(s) \4 sec(s)")|rex field=arr_sla_diff "^(?\d{1,2})\sday....(?\d{1,2})\shour...\s(?\d{1,2})\s"|eval dur_min=(day*1440+hour*60+minute)  |eval now_arr_diff=tostring((FILE_ARRIVALTIME_epoch-now_time_epoch), "duration")| eval now_arr_dif_day=replace(now_arr_diff,"(\d*)\+*(\d+):(\d+):(\d+)","\1 day(s) \2 hour(s) \3 minute(s) \4 sec(s)")|rex field=now_arr_dif_day "^(?\d{1,2})\sday....(?\d{1,2})\shour...\s(?\d{1,2})\s"|eval now_arr_min=(days*1440+hours*60+minutes) |eval now_sla_diff = if(isnull(FILE_ARRIVALTIME ), tostring(now_time_epoch - sla_time_epoch),null())|eval now_sla_diff = tostring(now_sla_diff, "duration")|table SOR_NAME FEED_NAME sla_time FILE_ARRIVALTIME  now_time   arr_sla_diff dur_min  now_arr_dif_day now_arr_min now_sla_diff
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Feb 2019 11:03:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/need-help-in-finding-the-time-differece-btween-two-fields-when/m-p/447733#M177003</guid>
      <dc:creator>pench2k19</dc:creator>
      <dc:date>2019-02-07T11:03:01Z</dc:date>
    </item>
  </channel>
</rss>

