<?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 a datetime string in the format yyyy-mm-ddT00:mm:ss.fffffffZ to a time to 3 milliseconds in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-a-datetime-string-in-the-format-yyyy-mm-ddT00-mm-ss/m-p/818315#M323008</link>
    <description>&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
    datetime=input('2022-05-16T02:30:00.2159663Z',e8601dz28.6);
    want_time=timepart(datetime);
    format want_time time12.3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: e8601dz in this case is an INFORMAT as it is used to read IN values. It is not a format in this case.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jun 2022 14:46:04 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-06-15T14:46:04Z</dc:date>
    <item>
      <title>Convert a datetime string in the format yyyy-mm-ddT00:mm:ss.fffffffZ to a time to 3 milliseconds?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-a-datetime-string-in-the-format-yyyy-mm-ddT00-mm-ss/m-p/818304#M323007</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I convert a datetime character string variable in the format &lt;STRONG&gt;yyyy-mm-ddThh-mm-ss.fffffffZ&lt;/STRONG&gt; to a time variable to 3 or more milliseconds and have that in a readable format e.g. hh:mm:ss:mmm.&lt;/P&gt;&lt;P&gt;An example I have is: &lt;STRONG&gt;2022-05-16T02:30:00.2159663Z&lt;/STRONG&gt; and I want a time variable in some format similar to this for example &lt;STRONG&gt;02:30:00:216.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have tried various ISO formats such as E8601DZ but haven't managed to find the solution yet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 14:29:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-a-datetime-string-in-the-format-yyyy-mm-ddT00-mm-ss/m-p/818304#M323007</guid>
      <dc:creator>BruceWayne</dc:creator>
      <dc:date>2022-06-15T14:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a datetime string in the format yyyy-mm-ddT00:mm:ss.fffffffZ to a time to 3 milliseconds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-a-datetime-string-in-the-format-yyyy-mm-ddT00-mm-ss/m-p/818315#M323008</link>
      <description>&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
    datetime=input('2022-05-16T02:30:00.2159663Z',e8601dz28.6);
    want_time=timepart(datetime);
    format want_time time12.3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: e8601dz in this case is an INFORMAT as it is used to read IN values. It is not a format in this case.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 14:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-a-datetime-string-in-the-format-yyyy-mm-ddT00-mm-ss/m-p/818315#M323008</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-15T14:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a datetime string in the format yyyy-mm-ddT00:mm:ss.fffffffZ to a time to 3 milliseconds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-a-datetime-string-in-the-format-yyyy-mm-ddT00-mm-ss/m-p/818337#M323015</link>
      <description>&lt;P&gt;To convert a string to a number you need to use and informat, not a format.&amp;nbsp; Formats convert values to text. Informats convert text to values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the E8601DZ informat to convert that string into a datetime value.&amp;nbsp; You can use the TIMEPART() function to extract just the time of day component from the datetime value.&lt;/P&gt;
&lt;P&gt;Note that you cannot store that many decimal places in a datetime value.&amp;nbsp; The number of decimal digits required would be more than SAS can store exactly in the binary floating point format it uses to store numbers.&lt;/P&gt;
&lt;PRE&gt;15   data test;
16     string = '2022-05-16T02:30:00.2159663Z';
17     dt = input(string,E8601DZ30.);
18     time = timepart(dt);
19     format dt datetime29.7 time tod16.7 ;
20     put (_all_) (=/);
21     put dt = 32.8 ;
22   run;


string=2022-05-16T02:30:00.2159663Z
dt=16MAY2022:02:30:00.2159662
time=02:30:00.2159662
dt=1968287400.21596000
&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Jun 2022 15:14:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-a-datetime-string-in-the-format-yyyy-mm-ddT00-mm-ss/m-p/818337#M323015</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-15T15:14:50Z</dc:date>
    </item>
  </channel>
</rss>

