<?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 Extraction of timepart from datetime in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extraction-of-timepart-from-datetime/m-p/298273#M270310</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to extarct timestamp (&lt;SPAN&gt;Time_var)&lt;/SPAN&gt; from sas &lt;SPAN&gt;Date_time&lt;/SPAN&gt;. The format of datetime is&amp;nbsp;&lt;SPAN&gt;11-07-2015 11:46:02&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;So, I used the following code which is not working. I doubt that the space between the date and time is causing the error.&lt;/P&gt;&lt;P&gt;Time_var=timepart(Date_time);&lt;/P&gt;</description>
    <pubDate>Wed, 14 Sep 2016 10:21:16 GMT</pubDate>
    <dc:creator>Revathi</dc:creator>
    <dc:date>2016-09-14T10:21:16Z</dc:date>
    <item>
      <title>Extraction of timepart from datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extraction-of-timepart-from-datetime/m-p/298273#M270310</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to extarct timestamp (&lt;SPAN&gt;Time_var)&lt;/SPAN&gt; from sas &lt;SPAN&gt;Date_time&lt;/SPAN&gt;. The format of datetime is&amp;nbsp;&lt;SPAN&gt;11-07-2015 11:46:02&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;So, I used the following code which is not working. I doubt that the space between the date and time is causing the error.&lt;/P&gt;&lt;P&gt;Time_var=timepart(Date_time);&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 10:21:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extraction-of-timepart-from-datetime/m-p/298273#M270310</guid>
      <dc:creator>Revathi</dc:creator>
      <dc:date>2016-09-14T10:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: Extraction of timepart from datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extraction-of-timepart-from-datetime/m-p/298276#M270311</link>
      <description>&lt;P&gt;The timepart() function extracts the time from a SAS datetime value, which must be a &lt;U&gt;number&lt;/U&gt; containing the seconds starting at 01jan1960:00:00:00.&lt;/P&gt;
&lt;P&gt;If your date_time is of type character, this won't work.&lt;/P&gt;
&lt;P&gt;You must convert first:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
x1 = '11-07-2015 11:46:02';
x2 = input(x1,anydtdtm19.);
x3 = timepart(x2);
format x2 datetime19. x3 time8.;
put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;16         data _null_;
17         x1 = '11-07-2015 11:46:02';
18         x2 = input(x1,anydtdtm19.);
19         x3 = timepart(x2);
20         format x2 datetime19. x3 time8.;
21         put _all_;
22         run;

x1=11-07-2015 11:46:02 x2=11JUL2015:11:46:02 x3=11:46:02 _ERROR_=0 _N_=1
&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Sep 2016 10:45:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extraction-of-timepart-from-datetime/m-p/298276#M270311</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-14T10:45:49Z</dc:date>
    </item>
  </channel>
</rss>

