<?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: Substract two dates in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Substract-two-dates/m-p/558394#M92387</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/233985"&gt;@boo_com&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;the way is the one in my previous answer, but you can display a number that means the second remaining, but not a date!&lt;/P&gt;&lt;P&gt;Why did you used that way to convert a date in epochtime?&lt;/P&gt;&lt;P&gt;you could easily run something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search
| eval date=strptime("06.07.2021","%d.%m.%Y")
| eval temp=relative_time(date,"1d@d+07h+15m")
| eval diff=temp-now()
| table diff&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jul 2021 12:24:47 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2021-07-06T12:24:47Z</dc:date>
    <item>
      <title>Substract two dates</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Substract-two-dates/m-p/558384#M92383</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am really struggling with subtracting&amp;nbsp; two dates from each other. It sounds that easy but drives me literally crazy.&lt;/P&gt;&lt;P&gt;All I want is, to subtract now() from a calculated date field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval temp = relative_time(a, b)
| eval newdate = temp - now()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;temp has a value of "1625634900.000000"&lt;/P&gt;&lt;P&gt;newdate will always be 01.01.1970. What am I missing?&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 11:33:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Substract-two-dates/m-p/558384#M92383</guid>
      <dc:creator>boo_com</dc:creator>
      <dc:date>2021-07-06T11:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: Substract two dates</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Substract-two-dates/m-p/558387#M92384</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/233985"&gt;@boo_com&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please share more details about a and b fields ??&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And why newdate will always be 01.01.1970. ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;KV&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 11:47:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Substract-two-dates/m-p/558387#M92384</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-07-06T11:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: Substract two dates</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Substract-two-dates/m-p/558388#M92385</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/233985"&gt;@boo_com&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if you convert the result of the relative_time&amp;nbsp; you have "2021-07-07" (in other words tomorrow!).&lt;/P&gt;&lt;P&gt;Let me understand:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;"a" is a date,&lt;/LI&gt;&lt;LI&gt;"b" id a time modifier (e.g. "-2d")&lt;/LI&gt;&lt;LI&gt;you calculate a new date using relative time, that seems to be in the future,&lt;/LI&gt;&lt;LI&gt;then you want to calculate the difference between the new date and now,&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;is it correct?&lt;/P&gt;&lt;P&gt;But in this way you haven't a date but a time difference between two dates, so it hasn't reason to display the difference in a date format.&lt;/P&gt;&lt;P&gt;Could you better describe your need?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 11:49:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Substract-two-dates/m-p/558388#M92385</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-07-06T11:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: Substract two dates</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Substract-two-dates/m-p/558390#M92386</link>
      <description>&lt;P&gt;Hi guys!&lt;/P&gt;&lt;P&gt;Thank you for your quick response! So Giuseppe explained it very well. I want to get the difference between two dates. One date is calculated, the other date is just now(). I want something like a countdown, printed in a new field showing the time left.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval date = strptime(substr("06.07.2021",7,4)+"/"+substr("06.07.2021",4,2)+"/"+substr("06.07.2021",0,2), "%Y/%m/%d")
| eval offset = @d+1d+07h+15m
| eval temp = relative_time(date, offset)&lt;/LI-CODE&gt;&lt;P&gt;date can be in the future or in the past.&lt;/P&gt;&lt;P&gt;How can I subtract temp from now() to receive the difference between those two dates?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 12:07:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Substract-two-dates/m-p/558390#M92386</guid>
      <dc:creator>boo_com</dc:creator>
      <dc:date>2021-07-06T12:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Substract two dates</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Substract-two-dates/m-p/558394#M92387</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/233985"&gt;@boo_com&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;the way is the one in my previous answer, but you can display a number that means the second remaining, but not a date!&lt;/P&gt;&lt;P&gt;Why did you used that way to convert a date in epochtime?&lt;/P&gt;&lt;P&gt;you could easily run something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search
| eval date=strptime("06.07.2021","%d.%m.%Y")
| eval temp=relative_time(date,"1d@d+07h+15m")
| eval diff=temp-now()
| table diff&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 12:24:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Substract-two-dates/m-p/558394#M92387</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-07-06T12:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: Substract two dates</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Substract-two-dates/m-p/558400#M92388</link>
      <description>&lt;P&gt;nice, thank you so much! The difference is returned in seconds. That way I easily can calculate remaining minutes, hours and days!&lt;/P&gt;&lt;P&gt;Yes you are right, I do not need the "substr" function &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 12:42:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Substract-two-dates/m-p/558400#M92388</guid>
      <dc:creator>boo_com</dc:creator>
      <dc:date>2021-07-06T12:42:20Z</dc:date>
    </item>
  </channel>
</rss>

