<?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: days information in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/days-information/m-p/485738#M83145</link>
    <description>&lt;P&gt;Hi @roopeshetty,&lt;BR /&gt;
you have to convert dates in epochtime and then use eval to subtract:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_search
| eval diff_days=(strptime(Validity,"%b %d,%Y")-now())/3600/24
| table Validity diff_days
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Eventually, you can round.&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jan 2020 12:51:06 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2020-01-21T12:51:06Z</dc:date>
    <item>
      <title>days information</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/days-information/m-p/485736#M83143</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;

&lt;P&gt;We have a field by name “Validity” which shows the validity date as below for different products;&lt;/P&gt;

&lt;P&gt;Validity : Dec 19, 2021&lt;/P&gt;

&lt;P&gt;Validity : Dec 11, 2022&lt;/P&gt;

&lt;P&gt;Validity : Mar 14, 2023&lt;/P&gt;

&lt;P&gt;Validity : Aug 24, 2021&lt;/P&gt;

&lt;P&gt;Here we need to create a field by name “DaysRemaining” which will have the values as number of days left from today by deducting the current date (of host running splunk ) with that Validity date. We will run that query once in every day so that the Days remaining will change every day.&lt;/P&gt;

&lt;P&gt;Can someone please help us with the splunk query?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 09:51:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/days-information/m-p/485736#M83143</guid>
      <dc:creator>roopeshetty</dc:creator>
      <dc:date>2020-01-21T09:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: days information</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/days-information/m-p/485737#M83144</link>
      <description>&lt;P&gt;Finding the difference between timestamps requires first converting them to epoch (integer) form.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval DaysRemaining = (now() - strptime(Validity, "%b %d, %Y")) / 86400
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jan 2020 12:48:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/days-information/m-p/485737#M83144</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-01-21T12:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: days information</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/days-information/m-p/485738#M83145</link>
      <description>&lt;P&gt;Hi @roopeshetty,&lt;BR /&gt;
you have to convert dates in epochtime and then use eval to subtract:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_search
| eval diff_days=(strptime(Validity,"%b %d,%Y")-now())/3600/24
| table Validity diff_days
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Eventually, you can round.&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2020 12:51:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/days-information/m-p/485738#M83145</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-01-21T12:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: days information</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/days-information/m-p/485739#M83146</link>
      <description>&lt;P&gt;Add this to the bottom of existing search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval Validity = strptime(Validity, "%b %d, %Y")
| fieldformat Validity = strftime(Validity, "%b %d, %Y")
| eval DaysRemaining = now() - Validity
| fieldformat DaysRemaining = tostring(DaysRemaining, "duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jan 2020 13:11:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/days-information/m-p/485739#M83146</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-01-21T13:11:05Z</dc:date>
    </item>
  </channel>
</rss>

