<?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: convert to datetime datatype and derive day,week,month,year from it... in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/convert-to-datetime-datatype-and-derive-day-week-month-year-from/m-p/701591#M20480</link>
    <description>&lt;P&gt;Ok. In order to reliably split a "variable format" time string you must have some strong assumptions you can make about it. For example, the order of the fields must be constant, the time specifier must be in a relatively well-defined format and so on. Otherwise you wouldn't be able to tell whether "10 23" means 10:23 AM or 23rd of October. Or maybe 10 minutes past some hour in 23rd day of some month. You must have something to anchor your extraction to.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Oct 2024 20:48:42 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2024-10-10T20:48:42Z</dc:date>
    <item>
      <title>convert to datetime datatype and derive day,week,month,year from it...</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/convert-to-datetime-datatype-and-derive-day-week-month-year-from/m-p/701534#M20471</link>
      <description>&lt;P&gt;Hi, Before asking i did try to find but not able to locate the thread that has this kind of datetime values..so i had to come up with this new thread&lt;/P&gt;&lt;P&gt;I have the datetime values in string format like&amp;nbsp;&lt;STRONG&gt;Thu 10 Oct 2024 08:48:12:574 EDT&amp;nbsp;&lt;/STRONG&gt;&amp;nbsp; sometimes there may be a null in it - thats how it is&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt; what is that i have to do with this is get/derive&amp;nbsp;into separate columns&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;day name like Thursday&lt;/P&gt;&lt;P&gt;day of month like 10&lt;/P&gt;&lt;P&gt;month like Oct&lt;BR /&gt;year 2024&lt;BR /&gt;week - weeknumber like 2 or 3&lt;/P&gt;&lt;P&gt;Time part into separate column like 08:48:12:57&amp;nbsp; - not worried about EDT&lt;/P&gt;&lt;P&gt;separate the time components into again&lt;BR /&gt;08 as Hour&lt;BR /&gt;48 as Min&lt;BR /&gt;12 as Sec&lt;BR /&gt;not worried about ms&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;still looking for threads with this kind of but...again sorry this is a basic one &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; just needs more searching&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 14:27:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/convert-to-datetime-datatype-and-derive-day-week-month-year-from/m-p/701534#M20471</guid>
      <dc:creator>Raj_Splunk_Ing</dc:creator>
      <dc:date>2024-10-10T14:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: convert to datetime datatype and derive day,week,month,year from it...</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/convert-to-datetime-datatype-and-derive-day-week-month-year-from/m-p/701536#M20472</link>
      <description>&lt;P&gt;Based on what I can understand, you can try using something like this and tweak it as needed.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval datetime_str="Thu 10 Oct 2024 08:48:12:574 EDT"
| eval datetime=strptime(datetime_str, "%a %d %b %Y %H:%M:%S:%3N %Z")
| eval day_name=strftime(datetime, "%A"),
day_of_month=strftime(datetime, "%d"),
month=strftime(datetime, "%b"),
year=strftime(datetime, "%Y"),
week_number=strftime(datetime, "%U"),
time_part=strftime(datetime, "%H:%M:%S")
| fields datetime_str, datetime, day_name, day_of_month, month, year, week_number, time_part
| eval hour=substr(time_part, 1, 2),
minute=substr(time_part, 4, 2),
second=substr(time_part, 7, 2)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 14:43:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/convert-to-datetime-datatype-and-derive-day-week-month-year-from/m-p/701536#M20472</guid>
      <dc:creator>sainag_splunk</dc:creator>
      <dc:date>2024-10-10T14:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: convert to datetime datatype and derive day,week,month,year from it...</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/convert-to-datetime-datatype-and-derive-day-week-month-year-from/m-p/701544#M20473</link>
      <description>&lt;P&gt;Hi sainag, Thank you so much for your quick response.&lt;BR /&gt;I was able to use your example and get it as follow - 2 things i noticed are&lt;BR /&gt;1 is the week number as 40 this should have been the october month week number&lt;BR /&gt;2 is the time part - i have 08.48.12 which is EST - but in my results i see it as 07.48.12&lt;BR /&gt;&lt;BR /&gt;ToDateTime1=strptime(TempDate1, "%a %d %b %Y %H:%M:%S:%3N %Z"),&lt;BR /&gt;Get_Day_Name=strftime(ToDateTime1, "%A"),&lt;BR /&gt;Get_Month_Num=strftime(ToDateTime1, "%d"),&lt;BR /&gt;Get_Month_Name=strftime(ToDateTime1, "%b"),&lt;BR /&gt;Get_Year=strftime(ToDateTime1, "%Y"),&lt;BR /&gt;&lt;STRONG&gt;Get_Week_Number=strftime(ToDateTime1, "%U"),&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Get_Time_Part=strftime(ToDateTime1, "%H:%M:%S")&lt;BR /&gt;&lt;BR /&gt;Thanks a lot&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 15:11:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/convert-to-datetime-datatype-and-derive-day-week-month-year-from/m-p/701544#M20473</guid>
      <dc:creator>Raj_Splunk_Ing</dc:creator>
      <dc:date>2024-10-10T15:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: convert to datetime datatype and derive day,week,month,year from it...</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/convert-to-datetime-datatype-and-derive-day-week-month-year-from/m-p/701546#M20474</link>
      <description>&lt;P&gt;Hi, figured out to get the week number based on the day number&amp;nbsp;&lt;/P&gt;&lt;P&gt;Get_Week_Number=floor(tonumber(strftime(ToDateTime1, "%d"))/7)+1,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;also adjusted my preferences to the datetime to show eastern&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 15:29:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/convert-to-datetime-datatype-and-derive-day-week-month-year-from/m-p/701546#M20474</guid>
      <dc:creator>Raj_Splunk_Ing</dc:creator>
      <dc:date>2024-10-10T15:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: convert to datetime datatype and derive day,week,month,year from it...</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/convert-to-datetime-datatype-and-derive-day-week-month-year-from/m-p/701591#M20480</link>
      <description>&lt;P&gt;Ok. In order to reliably split a "variable format" time string you must have some strong assumptions you can make about it. For example, the order of the fields must be constant, the time specifier must be in a relatively well-defined format and so on. Otherwise you wouldn't be able to tell whether "10 23" means 10:23 AM or 23rd of October. Or maybe 10 minutes past some hour in 23rd day of some month. You must have something to anchor your extraction to.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 20:48:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/convert-to-datetime-datatype-and-derive-day-week-month-year-from/m-p/701591#M20480</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-10-10T20:48:42Z</dc:date>
    </item>
  </channel>
</rss>

