<?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: Can't convert timeformat to unix in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-t-convert-timeformat-to-unix/m-p/747164#M241772</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/274960"&gt;@dtaylor&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;strptime expects a date/time string, not a duration.&lt;BR /&gt;Your field (Ended: 0d1h55m0s) is a duration (days, hours, minutes, seconds), not an absolute date/time.&lt;/P&gt;&lt;P&gt;try below,&lt;/P&gt;&lt;P&gt;| rex field=Time "Ended: (?&amp;lt;days&amp;gt;\d+)d(?&amp;lt;hours&amp;gt;\d+)h(?&amp;lt;minutes&amp;gt;\d+)m(?&amp;lt;seconds&amp;gt;\d+)s"&lt;BR /&gt;| eval duration = (days*86400) + (hours*3600) + (minutes*60) + seconds&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Prewin&lt;BR /&gt;Splunk Enthusiast | Always happy to help! If this answer helped you, please consider marking it as the solution or giving a kudos. Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 29 May 2025 03:49:21 GMT</pubDate>
    <dc:creator>PrewinThomas</dc:creator>
    <dc:date>2025-05-29T03:49:21Z</dc:date>
    <item>
      <title>Can't convert timeformat to unix</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-convert-timeformat-to-unix/m-p/747163#M241771</link>
      <description>&lt;P&gt;Hopefully I've only got a small problem this time, but I've had no luck fixing it despite hours of trying. All I'm trying to do is convert a string time field to unix using strptime. This is my time field:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Ended: 0d1h55m0s&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been trying to convert it to unix using the following command:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval time_sec = strptime('Time', "Ended: %dd%Hh%Mm%Ss")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For clarity, this is the full search:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup metrics.csv
| eval occurred=strftime(strptime(occurred,"%a, %d %b %Y %T %Z"), "%F %T %Z")
| eval closed=strftime(strptime(closed,"%a, %d %b %Y %T %Z"), "%F %T %Z")
| eval time_sec = strptime('Time', "Ended: %dd%Hh%Mm")
| where strptime(occurred, "%F %T") &amp;gt;= strptime("2025-05-01 00:00:00", "%F %T") AND (isnull(closeReason) OR closeReason="Resolved")
| fillnull value=Resolved closeReason&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The example time I've posted above 0d1h55m0s should ideally convert to 6900(seconds).&lt;/P&gt;</description>
      <pubDate>Thu, 29 May 2025 03:41:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-convert-timeformat-to-unix/m-p/747163#M241771</guid>
      <dc:creator>dtaylor</dc:creator>
      <dc:date>2025-05-29T03:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: Can't convert timeformat to unix</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-convert-timeformat-to-unix/m-p/747164#M241772</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/274960"&gt;@dtaylor&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;strptime expects a date/time string, not a duration.&lt;BR /&gt;Your field (Ended: 0d1h55m0s) is a duration (days, hours, minutes, seconds), not an absolute date/time.&lt;/P&gt;&lt;P&gt;try below,&lt;/P&gt;&lt;P&gt;| rex field=Time "Ended: (?&amp;lt;days&amp;gt;\d+)d(?&amp;lt;hours&amp;gt;\d+)h(?&amp;lt;minutes&amp;gt;\d+)m(?&amp;lt;seconds&amp;gt;\d+)s"&lt;BR /&gt;| eval duration = (days*86400) + (hours*3600) + (minutes*60) + seconds&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Prewin&lt;BR /&gt;Splunk Enthusiast | Always happy to help! If this answer helped you, please consider marking it as the solution or giving a kudos. Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 May 2025 03:49:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-convert-timeformat-to-unix/m-p/747164#M241772</guid>
      <dc:creator>PrewinThomas</dc:creator>
      <dc:date>2025-05-29T03:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can't convert timeformat to unix</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-t-convert-timeformat-to-unix/m-p/747171#M241774</link>
      <description>&lt;P&gt;In addition to&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/28010"&gt;@PrewinThomas&lt;/a&gt;'s breakdown method, I can suggest&amp;nbsp;&lt;A href="https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/latest/evaluation-functions/date-and-time-functions#ariaid-title3" target="_blank" rel="noopener"&gt;relative_time&lt;/A&gt;&amp;nbsp;to take advantage of Splunk's format strings.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval offset = replace('Time', "Ended: (\d+d)(\d+h)(\d+m)(\d+s)", "+\1+\2+\3")
| eval time_sec = relative_time(0, offset)&lt;/LI-CODE&gt;&lt;P&gt;relative_time's offset requires a + or a - before every time unit. &amp;nbsp;So, we transform&amp;nbsp;0d1h55m0s to&amp;nbsp;&lt;SPAN&gt;+0d+1h+55m.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 May 2025 06:02:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-t-convert-timeformat-to-unix/m-p/747171#M241774</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2025-05-29T06:02:24Z</dc:date>
    </item>
  </channel>
</rss>

