<?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: Filtering data from lookup csv file based on time difference in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-data-from-lookup-csv-file-based-on-time-difference/m-p/471681#M87714</link>
    <description>&lt;P&gt;I managed to solve this in the following manner. Though it may not be efficient but it worked for me.&lt;/P&gt;

&lt;P&gt;Instead of the date I kept the time as "seconds from epoch" in the csv file which looked like(assume the data is dummy).&lt;/P&gt;

&lt;P&gt;Day                  Messages&lt;BR /&gt;
12022020        1571&lt;BR /&gt;
12022020         302&lt;BR /&gt;
12022020         1&lt;/P&gt;

&lt;P&gt;Then using the following construct i was able to take a diff and compare it.&lt;BR /&gt;
| inputlookup abc.csv | eval today=relative_time(now(), "%d") | eval diff = today - Day | where diff &amp;lt;= 86400&lt;/P&gt;

&lt;P&gt;I am sure the strptime function should have done the job too with my previous approach but somehow in my case it didn't convert the date in the csv to date that can be compared. So I took this approach. Still trying to figure out why strptime didn't work.&lt;/P&gt;</description>
    <pubDate>Sat, 15 Feb 2020 06:51:18 GMT</pubDate>
    <dc:creator>sambit_kabi</dc:creator>
    <dc:date>2020-02-15T06:51:18Z</dc:date>
    <item>
      <title>Filtering data from lookup csv file based on time difference</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-data-from-lookup-csv-file-based-on-time-difference/m-p/471676#M87709</link>
      <description>&lt;P&gt;I have a lookup csv file which has the following data.&lt;BR /&gt;
Day                    Messages&lt;BR /&gt;
12/02/2020      1571&lt;BR /&gt;
12/02/2020      302&lt;BR /&gt;
12/02/2020          1&lt;/P&gt;

&lt;P&gt;What I want to do is read the Day column and then subtract the day from today's date to check if the difference is greater than 30.&lt;BR /&gt;
If the diff &amp;gt; 30 filter it out.  &lt;/P&gt;

&lt;P&gt;I tried the following query and it doesn't work.&lt;/P&gt;

&lt;P&gt;| inputlookup messages_per_day.csv | eval today=strftime(now(), "%d/%m/%Y") | eval diff=today - Day &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:11:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Filtering-data-from-lookup-csv-file-based-on-time-difference/m-p/471676#M87709</guid>
      <dc:creator>sambit_kabi</dc:creator>
      <dc:date>2020-09-30T04:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering data from lookup csv file based on time difference</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-data-from-lookup-csv-file-based-on-time-difference/m-p/471677#M87710</link>
      <description>&lt;P&gt;Timestamps cannot be compared in string form.  Try the inverse of your query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup messages_per_day.csv | eval today=strptime(Day, "%d/%m/%Y") | eval diff=now() - today
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Feb 2020 13:51:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Filtering-data-from-lookup-csv-file-based-on-time-difference/m-p/471677#M87710</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-02-13T13:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering data from lookup csv file based on time difference</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-data-from-lookup-csv-file-based-on-time-difference/m-p/471678#M87711</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| inputlookup messages_per_day.csv 
| where relative_time(now(),"-30d@d") &amp;lt; strptime(Day, "%d/%m/%Y")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Feb 2020 07:13:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Filtering-data-from-lookup-csv-file-based-on-time-difference/m-p/471678#M87711</guid>
      <dc:creator>spayneort</dc:creator>
      <dc:date>2020-02-14T07:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering data from lookup csv file based on time difference</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-data-from-lookup-csv-file-based-on-time-difference/m-p/471679#M87712</link>
      <description>&lt;P&gt;Thanks for the help. Unfortunately the strptime function didn't work for me. It didn't convert the time in csv to time to be compared. I don't get result for today variable. &lt;/P&gt;

&lt;P&gt;However I managed to find a solution by dumping the time in "secs from epoch" in the csv and then compared the diff between the today's start time with the time in csv.&lt;/P&gt;

&lt;P&gt;used constructs like | eval diff=relative_time(now(), "@d") - Day | where diff &amp;lt; 86400.&lt;/P&gt;

&lt;P&gt;Still wondering why strptime didn't work for me. However I found that | convert ctime(Day) did work for me.  &lt;/P&gt;</description>
      <pubDate>Sat, 15 Feb 2020 06:40:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Filtering-data-from-lookup-csv-file-based-on-time-difference/m-p/471679#M87712</guid>
      <dc:creator>sambit_kabi</dc:creator>
      <dc:date>2020-02-15T06:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering data from lookup csv file based on time difference</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-data-from-lookup-csv-file-based-on-time-difference/m-p/471680#M87713</link>
      <description>&lt;P&gt;Thanks for the help. I used the relative_time function as you pointed out. That came in handy.&lt;BR /&gt;
Unfortunately the strptime function didn't work for me as I have mentioned before. It didn't convert the time in csv to time to be compared. I don't get result for today variable.&lt;/P&gt;

&lt;P&gt;However I managed to find a solution by dumping the time in "secs from epoch" in the csv and then compared the diff between the today's start time with the time in csv.&lt;/P&gt;

&lt;P&gt;used constructs like | eval diff=relative_time(now(), "@d") - Day | where diff &amp;lt; 86400.&lt;/P&gt;

&lt;P&gt;Still wondering why strptime didn't work for me. However I found that | convert ctime(Day) did work for me &lt;/P&gt;

&lt;P&gt;Is there any condition that strptime has when used with inputlookup. Nothing mentioned in the documentation.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Feb 2020 06:43:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Filtering-data-from-lookup-csv-file-based-on-time-difference/m-p/471680#M87713</guid>
      <dc:creator>sambit_kabi</dc:creator>
      <dc:date>2020-02-15T06:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering data from lookup csv file based on time difference</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Filtering-data-from-lookup-csv-file-based-on-time-difference/m-p/471681#M87714</link>
      <description>&lt;P&gt;I managed to solve this in the following manner. Though it may not be efficient but it worked for me.&lt;/P&gt;

&lt;P&gt;Instead of the date I kept the time as "seconds from epoch" in the csv file which looked like(assume the data is dummy).&lt;/P&gt;

&lt;P&gt;Day                  Messages&lt;BR /&gt;
12022020        1571&lt;BR /&gt;
12022020         302&lt;BR /&gt;
12022020         1&lt;/P&gt;

&lt;P&gt;Then using the following construct i was able to take a diff and compare it.&lt;BR /&gt;
| inputlookup abc.csv | eval today=relative_time(now(), "%d") | eval diff = today - Day | where diff &amp;lt;= 86400&lt;/P&gt;

&lt;P&gt;I am sure the strptime function should have done the job too with my previous approach but somehow in my case it didn't convert the date in the csv to date that can be compared. So I took this approach. Still trying to figure out why strptime didn't work.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Feb 2020 06:51:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Filtering-data-from-lookup-csv-file-based-on-time-difference/m-p/471681#M87714</guid>
      <dc:creator>sambit_kabi</dc:creator>
      <dc:date>2020-02-15T06:51:18Z</dc:date>
    </item>
  </channel>
</rss>

