<?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 number to datetime with milliseconds in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/convert-number-to-datetime-with-milliseconds/m-p/670475#M85842</link>
    <description>&lt;P&gt;Seems like you have to have "." as separator within seconds&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

str = "20230818103947300000";
Insert Into(str, ".", Length("YYYYMMDDHHMMSS") +1);
date_formatted = Informat(str, "Format Pattern", "&amp;lt;YYYY&amp;gt;&amp;lt;MM&amp;gt;&amp;lt;DD&amp;gt;&amp;lt;hh24&amp;gt;&amp;lt;mm&amp;gt;&amp;lt;ss&amp;gt;");
date_with_ms = Format(date_formatted, "yyyy-mm-ddThh:mm:ss", 25,3); // "2023-08-18T10:39:47.300"&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 23 Aug 2023 08:56:53 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2023-08-23T08:56:53Z</dc:date>
    <item>
      <title>convert number to datetime with milliseconds</title>
      <link>https://community.jmp.com/t5/Discussions/convert-number-to-datetime-with-milliseconds/m-p/670450#M85839</link>
      <description>&lt;P&gt;Hi, I have a column with values of the following format: '20230818103947300000'&lt;/P&gt;&lt;P&gt;I was hoping to be able to convert it using the custom format (i.e. &amp;lt;YYYY&amp;gt;&amp;lt;MM&amp;gt;&amp;lt;dd&amp;gt; etc), but I do not see the option for milliseconds. Of course I can make a long formula to extract each individual element and then adding them together, but I really want to avoid that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For reference, in python I am able to do this in one line to get my datetime object dt:&lt;/P&gt;&lt;P&gt;from datetime import datetime&lt;BR /&gt;d='20230818103947300000'&lt;BR /&gt;dt=datetime.strptime(d,'%Y%m%d%H%M%S%f')&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 08:20:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/convert-number-to-datetime-with-milliseconds/m-p/670450#M85839</guid>
      <dc:creator>mvanderaa1</dc:creator>
      <dc:date>2023-08-23T08:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: convert number to datetime with milliseconds</title>
      <link>https://community.jmp.com/t5/Discussions/convert-number-to-datetime-with-milliseconds/m-p/670475#M85842</link>
      <description>&lt;P&gt;Seems like you have to have "." as separator within seconds&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

str = "20230818103947300000";
Insert Into(str, ".", Length("YYYYMMDDHHMMSS") +1);
date_formatted = Informat(str, "Format Pattern", "&amp;lt;YYYY&amp;gt;&amp;lt;MM&amp;gt;&amp;lt;DD&amp;gt;&amp;lt;hh24&amp;gt;&amp;lt;mm&amp;gt;&amp;lt;ss&amp;gt;");
date_with_ms = Format(date_formatted, "yyyy-mm-ddThh:mm:ss", 25,3); // "2023-08-18T10:39:47.300"&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Aug 2023 08:56:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/convert-number-to-datetime-with-milliseconds/m-p/670475#M85842</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-08-23T08:56:53Z</dc:date>
    </item>
  </channel>
</rss>

