<?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 How to filter events based on event's datetime as current date? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-filter-events-based-on-event-s-datetime-as-current-date/m-p/169618#M34282</link>
    <description>&lt;P&gt;Hello! Sup?&lt;BR /&gt;
I've been into some trouble when comparing datetimes to strings, I know I should convert'em.&lt;BR /&gt;
Logs I've received are in this format:&lt;/P&gt;

&lt;P&gt;CAMPAIGN_START_TIME&lt;BR /&gt;
00:01:05&lt;/P&gt;

&lt;P&gt;CAMPAIGN_END_TIME&lt;BR /&gt;
00:06:12&lt;/P&gt;

&lt;P&gt;CAMPAIGN_DATE&lt;BR /&gt;
04/08/2015&lt;/P&gt;

&lt;P&gt;So, what I did, was create a datetime based on these fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval CAMPAIGN_COMPLETE_DATE = (CAMPAIGN_DATE+ " " + CAMPAIGN_START_TIME)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The thing is, I need to make splunk filter results, based on this date, not the acctual _time filter.&lt;BR /&gt;
So I was gonna compare CAMPAIGN_COMPLETE_DATE to "Today"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Today = strftime(now(), "%d/%m/%Y %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I'm having some issues due to string comparisson to datetime.&lt;BR /&gt;
Does anyone know how can I solve this?&lt;BR /&gt;
Thanks in advance!&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;- Vinicius Guerrero&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 06:57:58 GMT</pubDate>
    <dc:creator>vtsguerrero</dc:creator>
    <dc:date>2020-09-29T06:57:58Z</dc:date>
    <item>
      <title>How to filter events based on event's datetime as current date?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-filter-events-based-on-event-s-datetime-as-current-date/m-p/169618#M34282</link>
      <description>&lt;P&gt;Hello! Sup?&lt;BR /&gt;
I've been into some trouble when comparing datetimes to strings, I know I should convert'em.&lt;BR /&gt;
Logs I've received are in this format:&lt;/P&gt;

&lt;P&gt;CAMPAIGN_START_TIME&lt;BR /&gt;
00:01:05&lt;/P&gt;

&lt;P&gt;CAMPAIGN_END_TIME&lt;BR /&gt;
00:06:12&lt;/P&gt;

&lt;P&gt;CAMPAIGN_DATE&lt;BR /&gt;
04/08/2015&lt;/P&gt;

&lt;P&gt;So, what I did, was create a datetime based on these fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval CAMPAIGN_COMPLETE_DATE = (CAMPAIGN_DATE+ " " + CAMPAIGN_START_TIME)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The thing is, I need to make splunk filter results, based on this date, not the acctual _time filter.&lt;BR /&gt;
So I was gonna compare CAMPAIGN_COMPLETE_DATE to "Today"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Today = strftime(now(), "%d/%m/%Y %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I'm having some issues due to string comparisson to datetime.&lt;BR /&gt;
Does anyone know how can I solve this?&lt;BR /&gt;
Thanks in advance!&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;- Vinicius Guerrero&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 06:57:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-filter-events-based-on-event-s-datetime-as-current-date/m-p/169618#M34282</guid>
      <dc:creator>vtsguerrero</dc:creator>
      <dc:date>2020-09-29T06:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter events based on event's datetime as current date?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-filter-events-based-on-event-s-datetime-as-current-date/m-p/169619#M34283</link>
      <description>&lt;P&gt;Hi vtsguerrero,&lt;/P&gt;

&lt;P&gt;you can use &lt;CODE&gt;strptime&lt;/CODE&gt; on the CAMPAIGN_COMPLETE_DATE like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval Today = strftime(now(), "%d/%m/%Y %H:%M:%S") | eval searchTime = strptime(CAMPAIGN_COMPLETE_DATE, "%d/%m/%Y %H:%M:%S") | where searchTime  = Today  | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;From the docs &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.4/SearchReference/CommonEvalFunctions" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.4/SearchReference/CommonEvalFunctions&lt;/A&gt; about &lt;CODE&gt;strptime&lt;/CODE&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;This function takes an epochtime value, X, as the first argument and renders it as a string using the format specified by Y.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 06:58:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-filter-events-based-on-event-s-datetime-as-current-date/m-p/169619#M34283</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2020-09-29T06:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter events based on event's datetime as current date?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-filter-events-based-on-event-s-datetime-as-current-date/m-p/169620#M34284</link>
      <description>&lt;P&gt;Is it possible to filter between datetimes of event date?&lt;BR /&gt;
For example, I need to filter a window between 23:00:00 and 06:00:00 but of the current day.&lt;BR /&gt;
Considering current day as event date, is it possible to achieve this datetime window?&lt;BR /&gt;
Thanks in advance @ MuS ♦&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2015 20:21:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-filter-events-based-on-event-s-datetime-as-current-date/m-p/169620#M34284</guid>
      <dc:creator>vtsguerrero</dc:creator>
      <dc:date>2015-08-14T20:21:11Z</dc:date>
    </item>
  </channel>
</rss>

