<?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 do you use strptime with different date formats? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-strptime-with-different-date-formats/m-p/376685#M110583</link>
    <description>&lt;P&gt;Try wrapping your strptime calls in coalsece like this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;eval LastSeen_epoch = coalesce(strptime('LastSeen', "%m/%d/%Y %H:%M"),strptime('LastSeen', "%m/%d/%y %H:%M"))&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This should return the epoch time for the first format which can be successfully used to parse LastSeen. &lt;/P&gt;</description>
    <pubDate>Wed, 02 Jan 2019 13:20:13 GMT</pubDate>
    <dc:creator>t_hartmann</dc:creator>
    <dc:date>2019-01-02T13:20:13Z</dc:date>
    <item>
      <title>How do you use strptime with different date formats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-strptime-with-different-date-formats/m-p/376683#M110581</link>
      <description>&lt;P&gt;I have two date formats coming into my index (01/11/2018) and (01/11/18). I wrote: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval LastSeen_epoch = strptime('LastSeen', "%m/%d/%Y %H:%M"),strptime('LastSeen', "%m/%d/%y %H:%M")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, this does not work to convert both types that are coming in. (Y and y) are the differences.&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Mon, 05 Nov 2018 16:31:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-strptime-with-different-date-formats/m-p/376683#M110581</guid>
      <dc:creator>JoshuaJohn</dc:creator>
      <dc:date>2018-11-05T16:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use strptime with different date formats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-strptime-with-different-date-formats/m-p/376684#M110582</link>
      <description>&lt;P&gt;Check the length of your "Last_date" field using  len() function, if length is 8 then use %y format else if length is 10 use %Y format. Let me know if you need help forming the query.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Nov 2018 17:37:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-strptime-with-different-date-formats/m-p/376684#M110582</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2018-11-05T17:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use strptime with different date formats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-strptime-with-different-date-formats/m-p/376685#M110583</link>
      <description>&lt;P&gt;Try wrapping your strptime calls in coalsece like this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;eval LastSeen_epoch = coalesce(strptime('LastSeen', "%m/%d/%Y %H:%M"),strptime('LastSeen', "%m/%d/%y %H:%M"))&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This should return the epoch time for the first format which can be successfully used to parse LastSeen. &lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 13:20:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-strptime-with-different-date-formats/m-p/376685#M110583</guid>
      <dc:creator>t_hartmann</dc:creator>
      <dc:date>2019-01-02T13:20:13Z</dc:date>
    </item>
  </channel>
</rss>

