<?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 to convert Modified Julian Date (MJD) to human readable in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-Modified-Julian-Date-MJD-to-human-readable/m-p/658037#M227295</link>
    <description>&lt;P&gt;This run-anywhere example shows how to convert MJD into a text date.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval StartDateTime="59025.5249306" 
``` Extract the day number (prior to .) ```
| rex field=StartDateTime "(?&amp;lt;JD&amp;gt;\d+)" 
``` Shift the day number to base epoch day and convert to seconds ```
| eval time=(JD-40587) * 86400 
``` Convert to text ```
| eval humanTime=strftime(time, "%c")&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 19 Sep 2023 17:16:15 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2023-09-19T17:16:15Z</dc:date>
    <item>
      <title>How to convert Modified Julian Date (MJD) to human readable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-Modified-Julian-Date-MJD-to-human-readable/m-p/658028#M227291</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;i have read similar posts but none that will get me to an answer.&lt;/P&gt;&lt;P&gt;My log entry is this;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;2023-09-19&lt;/SPAN&gt; &lt;SPAN class=""&gt;16:17:01&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;306&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;OnAirSchedule&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;Service=&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;9008&lt;/SPAN&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;SPAN class=""&gt;Status=&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;ON&lt;/SPAN&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;SPAN class=""&gt;StartDateTime=&lt;/SPAN&gt;&lt;SPAN&gt;"59025.5249306&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;BR /&gt;&lt;BR /&gt;The StartDateTime is in MJD and i would like to get into human readable format.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Below is my search, some regex to start with then the conversion.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "&amp;lt;OnAirSchedule\sService=\"(?&amp;lt;SERVICE&amp;gt;[0-9]+)\"\sStatus\=\"(?&amp;lt;STATUS&amp;gt;.+)\"\sStartDateTime\=\"(?&amp;lt;START_DATE&amp;gt;.+)\"\/\&amp;gt;"

| eval jdate=START_DATE,epoch_date=strptime(jdate,"%y%j"),date=strftime(epoch_date,"%Y-%m-%d %H:%M:%S.%1N")
| table _time SI_SERVICE_KEY STATUS START_DATE epoch_date date&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;which was a solution in another question, however i get the date time&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2059-01-25 00:00:00.0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have tried variances&amp;nbsp;of the %y%j to %y.%j and %Y.%j, however these just seem to deal with the date as Julian Date, rather than using the values after the decimal point.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This page seems to point to something i am after but it doesnt deal with the full MJD.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://community.splunk.com/t5/Getting-Data-In/Splunk-recognizing-Julian-Date-and-Elapsed-Seconds/m-p/72709" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Getting-Data-In/Splunk-recognizing-Julian-Date-and-Elapsed-Seconds/m-p/72709&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;any advice greatly welcomed.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2023 16:42:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-Modified-Julian-Date-MJD-to-human-readable/m-p/658028#M227291</guid>
      <dc:creator>ssaenger</dc:creator>
      <dc:date>2023-09-19T16:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Modified Julian Date (MJD) to human readable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-Modified-Julian-Date-MJD-to-human-readable/m-p/658037#M227295</link>
      <description>&lt;P&gt;This run-anywhere example shows how to convert MJD into a text date.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval StartDateTime="59025.5249306" 
``` Extract the day number (prior to .) ```
| rex field=StartDateTime "(?&amp;lt;JD&amp;gt;\d+)" 
``` Shift the day number to base epoch day and convert to seconds ```
| eval time=(JD-40587) * 86400 
``` Convert to text ```
| eval humanTime=strftime(time, "%c")&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 19 Sep 2023 17:16:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-Modified-Julian-Date-MJD-to-human-readable/m-p/658037#M227295</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-09-19T17:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Modified Julian Date (MJD) to human readable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-Modified-Julian-Date-MJD-to-human-readable/m-p/658041#M227298</link>
      <description>&lt;P&gt;Hi Rich,&lt;BR /&gt;Thank you for your reply.&lt;BR /&gt;I have run the command and added some extra as I was also after the time, however i think you chop the seconds off.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval StartDateTime="59025.5249306" 
``` Extract the day number (prior to .) ```
| rex field=StartDateTime "(?&amp;lt;JD&amp;gt;\d+)" 
``` Shift the day number to base epoch day and convert to seconds ```
| eval time=(JD-40587) * 86400 
``` Convert to text ```
| eval humanTime=strftime(time, "%c")
| eval humanTime1=strftime(time, "%Y-%m-%d %H:%M:%S.%1N")
| table _time StartDateTime JD time humanTime humanTime1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this gives,&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;2020-06-25 00:00:00.0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;do we have to extract the seconds and add them back to epoch?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2023 17:31:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-Modified-Julian-Date-MJD-to-human-readable/m-p/658041#M227298</guid>
      <dc:creator>ssaenger</dc:creator>
      <dc:date>2023-09-19T17:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Modified Julian Date (MJD) to human readable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-Modified-Julian-Date-MJD-to-human-readable/m-p/658050#M227300</link>
      <description>&lt;P&gt;To include the time component, we don't need to extract anything.&amp;nbsp; Just treat StartDateTime as a floating point number.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval StartDateTime="59025.5249306" 
| eval time=(StartTime-40587) * 86400 
| eval humanTime=strftime(time, "%c")&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 19 Sep 2023 19:42:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-Modified-Julian-Date-MJD-to-human-readable/m-p/658050#M227300</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-09-19T19:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Modified Julian Date (MJD) to human readable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-Modified-Julian-Date-MJD-to-human-readable/m-p/658054#M227302</link>
      <description>&lt;P&gt;Hi Rich,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Brilliant!, thank you thank worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2023 20:21:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-Modified-Julian-Date-MJD-to-human-readable/m-p/658054#M227302</guid>
      <dc:creator>ssaenger</dc:creator>
      <dc:date>2023-09-19T20:21:40Z</dc:date>
    </item>
  </channel>
</rss>

