<?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 Between two timestamp fields, how to compare and determine which timestamp is the later time? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Between-two-timestamp-fields-how-to-compare-and-determine-which/m-p/322713#M60100</link>
    <description>&lt;P&gt;First, I'd like to apologize because I am new to Splunk development, and am trying to learn how to do things.&lt;/P&gt;

&lt;P&gt;I have timestamp fields (formatted %Y-%m-%d %H:%M:%S) from two different sources, timeA and timeB.  I've got both sources successfully joined, but now I need to compare the two fields and determine which date is the later date.  I want to assign the later of the two dates to a new field.  Also, sometimes either date could be blank (and in a few cases, they're both blank).&lt;/P&gt;

&lt;P&gt;Does anyone know how to do this?  I've had a hard time figuring anything out in the docs.&lt;/P&gt;

&lt;P&gt;TIA,&lt;BR /&gt;
Ryan&lt;/P&gt;</description>
    <pubDate>Wed, 22 Feb 2017 16:56:13 GMT</pubDate>
    <dc:creator>bretai2k</dc:creator>
    <dc:date>2017-02-22T16:56:13Z</dc:date>
    <item>
      <title>Between two timestamp fields, how to compare and determine which timestamp is the later time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Between-two-timestamp-fields-how-to-compare-and-determine-which/m-p/322713#M60100</link>
      <description>&lt;P&gt;First, I'd like to apologize because I am new to Splunk development, and am trying to learn how to do things.&lt;/P&gt;

&lt;P&gt;I have timestamp fields (formatted %Y-%m-%d %H:%M:%S) from two different sources, timeA and timeB.  I've got both sources successfully joined, but now I need to compare the two fields and determine which date is the later date.  I want to assign the later of the two dates to a new field.  Also, sometimes either date could be blank (and in a few cases, they're both blank).&lt;/P&gt;

&lt;P&gt;Does anyone know how to do this?  I've had a hard time figuring anything out in the docs.&lt;/P&gt;

&lt;P&gt;TIA,&lt;BR /&gt;
Ryan&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 16:56:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Between-two-timestamp-fields-how-to-compare-and-determine-which/m-p/322713#M60100</guid>
      <dc:creator>bretai2k</dc:creator>
      <dc:date>2017-02-22T16:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Between two timestamp fields, how to compare and determine which timestamp is the later time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Between-two-timestamp-fields-how-to-compare-and-determine-which/m-p/322714#M60101</link>
      <description>&lt;P&gt;You need to determine whether timestamp is in epoch format or string format. If they are string time you need to convert to epoch first. Try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;Your Base Search&amp;gt;
| eval Time1=if(isnull(Time1),0,Time1)
| eval Time2=if(isnull(Time2),0,Time2)
| eval Time3=if(Time1&amp;gt;Time2,Time1,Time2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For understanding time fields and conversions you can check out &lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions#Date_and_Time_functions"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions#Date_and_Time_functions&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Convert"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Convert&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Commontimeformatvariables"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Commontimeformatvariables&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 19:40:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Between-two-timestamp-fields-how-to-compare-and-determine-which/m-p/322714#M60101</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-02-22T19:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Between two timestamp fields, how to compare and determine which timestamp is the later time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Between-two-timestamp-fields-how-to-compare-and-determine-which/m-p/322715#M60102</link>
      <description>&lt;P&gt;Worked perfectly!  Thank you niketnilay&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 20:39:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Between-two-timestamp-fields-how-to-compare-and-determine-which/m-p/322715#M60102</guid>
      <dc:creator>bretai2k</dc:creator>
      <dc:date>2017-02-22T20:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Between two timestamp fields, how to compare and determine which timestamp is the later time?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Between-two-timestamp-fields-how-to-compare-and-determine-which/m-p/322716#M60103</link>
      <description>&lt;P&gt;In the given format, they can be compared directly.  Year, month, day, hour, minute, second are already in descending order of significance.  The only caveat is whether they are in the same time zone, but you don't have a time zone qualifier (%Z) on the format, so you can just say &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;if(timeA &amp;lt; timeB,timeB,timeA)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 00:33:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Between-two-timestamp-fields-how-to-compare-and-determine-which/m-p/322716#M60103</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-23T00:33:28Z</dc:date>
    </item>
  </channel>
</rss>

