<?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: Age calculation based on Date in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Age-calculation-based-on-Date/m-p/415278#M119566</link>
    <description>&lt;P&gt;Expressions in &lt;CODE&gt;case&lt;/CODE&gt; statements are evaluated left-to-right and stop at the first match.  That means a date older than 365 days will match the "Older than 60 Days" case because 365 &amp;gt; 60.  To get the results you desire, change the order of expressions.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval age=ceiling((now()-strptime(date,"%Y-%m-%d"))/86400)
| eval Vulnerability_Age=case(
age&amp;lt;30,"Less than 30 Days",
age&amp;gt;=365,"&amp;gt;Older than 1 Year",
age&amp;gt;=180,"Older than 180 Days",
age&amp;gt;=120,"Older than 120 Days",
age&amp;gt;=90,"Older than 90 Days",
age&amp;gt;=60,"Older than 60 Days",
0==0,"No Age Data")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 26 Jul 2019 18:51:56 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2019-07-26T18:51:56Z</dc:date>
    <item>
      <title>Age calculation based on Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Age-calculation-based-on-Date/m-p/415277#M119565</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a field in my data that is called "date". This "date" is when a vulnerability was seen the first time. I need a calculation that allows me to do following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;30,"Less than 30 Days"
30-60,"30-60 Days"
60-90,"60-90 Days"
90-180,"90-180 Days"
180-365,"30 Days to 1 Year"
&amp;gt;365,"Over 1 Year"
0==0,"No Age Data"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I used below. It works BUT it is not breaking down the way I need. Instead, below is generating &amp;lt;30 Days, No Age Data and Over 60 Days. So basically, everything that is over 60 which is the second statement in second EVAL below is being added in Over 60 field. I need them separate.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval age=ceiling((now()-strptime(date,"%Y-%m-%d"))/86400)
| eval Vulnerability_Age=case(
age&amp;lt;30,"Less than 30 Days",
age&amp;gt;=60,"Older than 60 Days",
age&amp;gt;=90,"Older than 90 Days",
age&amp;gt;=120,"Older than 120 Days",
age&amp;gt;=180,"Older than 180 Days",
age&amp;gt;=365,"&amp;gt;Older than 1 Year",
0==0,"No Age Data")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks in-advance!!!!&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2019 18:40:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Age-calculation-based-on-Date/m-p/415277#M119565</guid>
      <dc:creator>mbasharat</dc:creator>
      <dc:date>2019-07-26T18:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Age calculation based on Date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Age-calculation-based-on-Date/m-p/415278#M119566</link>
      <description>&lt;P&gt;Expressions in &lt;CODE&gt;case&lt;/CODE&gt; statements are evaluated left-to-right and stop at the first match.  That means a date older than 365 days will match the "Older than 60 Days" case because 365 &amp;gt; 60.  To get the results you desire, change the order of expressions.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval age=ceiling((now()-strptime(date,"%Y-%m-%d"))/86400)
| eval Vulnerability_Age=case(
age&amp;lt;30,"Less than 30 Days",
age&amp;gt;=365,"&amp;gt;Older than 1 Year",
age&amp;gt;=180,"Older than 180 Days",
age&amp;gt;=120,"Older than 120 Days",
age&amp;gt;=90,"Older than 90 Days",
age&amp;gt;=60,"Older than 60 Days",
0==0,"No Age Data")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Jul 2019 18:51:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Age-calculation-based-on-Date/m-p/415278#M119566</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-07-26T18:51:56Z</dc:date>
    </item>
  </channel>
</rss>

