<?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: How To Compare Dates Between Two Different Sourcetypes in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-To-Compare-Dates-Between-Two-Different-Sourcetypes/m-p/290680#M55433</link>
    <description>&lt;P&gt;@ebruozys, can you add the background of what is the process for your use case? Why and how do you get sourcetype of an event changed to a new one and purged from the original?&lt;/P&gt;</description>
    <pubDate>Mon, 20 Nov 2017 16:43:09 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-11-20T16:43:09Z</dc:date>
    <item>
      <title>How To Compare Dates Between Two Different Sourcetypes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-To-Compare-Dates-Between-Two-Different-Sourcetypes/m-p/290677#M55430</link>
      <description>&lt;P&gt;I want to calculate how long it takes until a event from one sourcetype switches to another sourcetype. For example event with ID 12345 enters sourcetype "start" on 2017-10-17 on 2017-10-30 it disapears from sourcetype 'start' and enters sourcetype "second_stage".  I want to know how many days it took for to go to the second stage. &lt;/P&gt;

&lt;P&gt;So far I have tried the following command &lt;BR /&gt;
(index="test" source="start") OR (index="test" source="second_stage") ID=12345 | eval Start_Date=strptime(STARTDATE, "%Y-%m-%d %H:%M:%S."%N") | eval SecondStage_Date=strptime(SECONDSTAGEDATE,"%Y-%m-%d %H:%M:%S.%N") | eval Duration=floor((SecondStage_Date-Start_Date)/86400)&lt;/P&gt;

&lt;P&gt;On execution of the search the field Duration stays empty. I asume that somehow I need to combine the Start_Date and SecondStage_Date to the ID, but I have no idea how to do that. &lt;/P&gt;

&lt;P&gt;Does anybody else know how to do that?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:50:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-To-Compare-Dates-Between-Two-Different-Sourcetypes/m-p/290677#M55430</guid>
      <dc:creator>ebruozys</dc:creator>
      <dc:date>2020-09-29T16:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: How To Compare Dates Between Two Different Sourcetypes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-To-Compare-Dates-Between-Two-Different-Sourcetypes/m-p/290678#M55431</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;If you want to calculate difference by &lt;CODE&gt;ID&lt;/CODE&gt; then you can try below query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index="test" source="start") OR (index="test" source="second_stage") ID=12345 | eval Start_Date=strptime(STARTDATE, "%Y-%m-%d %H:%M:%S."%N") | eval SecondStage_Date=strptime(SECONDSTAGEDATE,"%Y-%m-%d %H:%M:%S.%N") | stats values(eval(floor((SecondStage_Date-Start_Date)/86400))) AS Duration by ID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can you please let us know how your timestamp looks like in &lt;CODE&gt;STARTDATE&lt;/CODE&gt; and &lt;CODE&gt;SECONDSTAGEDATE&lt;/CODE&gt; field?&lt;/P&gt;

&lt;P&gt;EDIT: Updated query&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 15:03:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-To-Compare-Dates-Between-Two-Different-Sourcetypes/m-p/290678#M55431</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-11-20T15:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: How To Compare Dates Between Two Different Sourcetypes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-To-Compare-Dates-Between-Two-Different-Sourcetypes/m-p/290679#M55432</link>
      <description>&lt;P&gt;Hi  ebruozys,&lt;BR /&gt;
try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index="test" source="start") OR (index="test" source="second_stage") ID=12345
| stats earliest(STARTDATE) AS STARTDATE earliest(SECONDSTAGEDATE) AS SECONDSTAGEDATE
| eval 
     Start_Date=strptime(STARTDATE, "%Y-%m-%d %H:%M:%S."%N"),
     SecondStage_Date=strptime(SECONDSTAGEDATE,"%Y-%m-%d %H:%M:%S.%N"),
     Duration=floor((SecondStage_Date-Start_Date)/86400)
| table STARTDATE SECONDSTAGEDATE Duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I prefer to use tostring funtion to show durations, in other words replace last eval with &lt;CODE&gt;Duration=tostring(SecondStage_Date-Start_Date,"duration")&lt;/CODE&gt;&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 15:29:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-To-Compare-Dates-Between-Two-Different-Sourcetypes/m-p/290679#M55432</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-11-20T15:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: How To Compare Dates Between Two Different Sourcetypes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-To-Compare-Dates-Between-Two-Different-Sourcetypes/m-p/290680#M55433</link>
      <description>&lt;P&gt;@ebruozys, can you add the background of what is the process for your use case? Why and how do you get sourcetype of an event changed to a new one and purged from the original?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 16:43:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-To-Compare-Dates-Between-Two-Different-Sourcetypes/m-p/290680#M55433</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-11-20T16:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: How To Compare Dates Between Two Different Sourcetypes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-To-Compare-Dates-Between-Two-Different-Sourcetypes/m-p/290681#M55434</link>
      <description>&lt;P&gt;Hi Giuseppe,&lt;/P&gt;

&lt;P&gt;Thank you for your response. &lt;/P&gt;

&lt;P&gt;I realise my original question wasn't complete. &lt;/P&gt;

&lt;P&gt;What if I want to get a list of multiple ID's? &lt;BR /&gt;
Sow imagine I dont have a specific ID, I just want to get a list of ID's and the Duration per ID of how long it took for it to reach the second stage. I tried adding a 'chart count by duration', but all I seem to get is a count of total duration.&lt;/P&gt;

&lt;P&gt;Greetings,&lt;BR /&gt;
Evald&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2017 08:35:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-To-Compare-Dates-Between-Two-Different-Sourcetypes/m-p/290681#M55434</guid>
      <dc:creator>ebruozys</dc:creator>
      <dc:date>2017-11-22T08:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: How To Compare Dates Between Two Different Sourcetypes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-To-Compare-Dates-Between-Two-Different-Sourcetypes/m-p/290682#M55435</link>
      <description>&lt;P&gt;Hi ebruozys,&lt;BR /&gt;
if you have multiple IDs insert this clause in stats command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index="test" source="start") OR (index="test" source="second_stage")
 | stats earliest(STARTDATE) AS STARTDATE earliest(SECONDSTAGEDATE) AS SECONDSTAGEDATE BY ID
 | eval 
      Start_Date=strptime(STARTDATE, "%Y-%m-%d %H:%M:%S."%N"),
      SecondStage_Date=strptime(SECONDSTAGEDATE,"%Y-%m-%d %H:%M:%S.%N"),
      Duration=floor((SecondStage_Date-Start_Date)/86400)
 | table ID STARTDATE SECONDSTAGEDATE Duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2017 12:14:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-To-Compare-Dates-Between-Two-Different-Sourcetypes/m-p/290682#M55435</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-11-22T12:14:27Z</dc:date>
    </item>
  </channel>
</rss>

