<?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: strptime works when using makeresults, but not with actual results in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/strptime-works-when-using-makeresults-but-not-with-actual/m-p/682971#M233279</link>
    <description>&lt;P&gt;Minor point, but the number of seconds in a day is 86400, not 86000.&lt;/P&gt;</description>
    <pubDate>Wed, 03 Apr 2024 07:38:57 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2024-04-03T07:38:57Z</dc:date>
    <item>
      <title>strptime works when using makeresults, but not with actual results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/strptime-works-when-using-makeresults-but-not-with-actual/m-p/682738#M233239</link>
      <description>&lt;P&gt;I have a dataset of user data including the user's LastLogin. The LastLogin field is slightly oddly formatted but very regular in it's pattern. I wish to calculate the number of days since LastLogin. This should be super simple.&lt;/P&gt;&lt;P&gt;What is bizarre is that in a contrived example using &lt;STRONG&gt;makeresults&lt;/STRONG&gt; it works perfectly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;| makeresults
| eval LastLogin="Mar 20, 2024, 16:40"
| eval lastactive=strptime(LastLogin, "%b %d, %Y, %H:%M")
| eval dayslastactive=round((now() - lastactive) / 86000, 0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This yields:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2024-04-02_13-46-05.png" style="width: 526px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/30015i84E3A5914AC258A5/image-dimensions/526x25?v=v2" width="526" height="25" role="button" title="2024-04-02_13-46-05.png" alt="2024-04-02_13-46-05.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But with the &lt;STRONG&gt;actual&lt;/STRONG&gt; results the same transformations do not work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;| inputlookup MSOLUsers 
| where match(onPremisesDistinguishedName, "OU=Users") 
| where not isnull(LastLogin)
| eval LastActive=strptime(LastLogin, "%b %d, %Y, %H:%M")
| eval DaysLastActive=round((now() - LastActive) / 86000, 0)
| fields Company, Department, DisplayName, LastLogin, LastActive, DaysLastActive&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This yields:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2024-04-02_13-50-23.png" style="width: 611px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/30017i187D25EC4D8534C2/image-dimensions/611x97?v=v2" width="611" height="97" role="button" title="2024-04-02_13-50-23.png" alt="2024-04-02_13-50-23.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What am I missing? Cutting and pasting the strings into the &lt;STRONG&gt;makeresults&lt;/STRONG&gt; form gives what I would expect.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 12:53:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/strptime-works-when-using-makeresults-but-not-with-actual/m-p/682738#M233239</guid>
      <dc:creator>raoul</dc:creator>
      <dc:date>2024-04-02T12:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: strptime works when using makeresults, but not with actual results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/strptime-works-when-using-makeresults-but-not-with-actual/m-p/682959#M233275</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1640"&gt;@raoul&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Maybe spaces in your LastLogin field are unprintable characters. Can you try below query which cleans all whitespace?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup MSOLUsers 
| where match(onPremisesDistinguishedName, "OU=Users") 
| where not isnull(LastLogin)
| eval LastLogin=replace(LastLogin,"[^A-Za-z0-9,:]+","")
| eval LastActive=strptime(LastLogin, "%b%d,%Y,%H:%M")
| eval DaysLastActive=round((now() - LastActive) / 86000, 0)
| fields Company, Department, DisplayName, LastLogin, LastActive, DaysLastActive&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 03 Apr 2024 05:19:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/strptime-works-when-using-makeresults-but-not-with-actual/m-p/682959#M233275</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2024-04-03T05:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: strptime works when using makeresults, but not with actual results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/strptime-works-when-using-makeresults-but-not-with-actual/m-p/682971#M233279</link>
      <description>&lt;P&gt;Minor point, but the number of seconds in a day is 86400, not 86000.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 07:38:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/strptime-works-when-using-makeresults-but-not-with-actual/m-p/682971#M233279</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-04-03T07:38:57Z</dc:date>
    </item>
  </channel>
</rss>

