<?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: Extracting date, month, year and time from a datetime variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extracting-date-month-year-and-time-from-a-datetime-variable/m-p/252486#M268801</link>
    <description>&lt;P&gt;1. Datepart() function to extract date&lt;/P&gt;
&lt;P&gt;2. Timepart() function to extract time&lt;/P&gt;
&lt;P&gt;3. Year(), Month(), Day() function to extract date components - reference variable from #1&lt;/P&gt;</description>
    <pubDate>Thu, 25 Feb 2016 19:03:34 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-02-25T19:03:34Z</dc:date>
    <item>
      <title>Extracting date, month, year and time from a datetime variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-date-month-year-and-time-from-a-datetime-variable/m-p/252483#M268800</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can some one help me with extracting DAY, MONTH, YEAR and Time from the below format....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2015-08-27T 8:36:00&lt;/P&gt;
&lt;P&gt;2014-09-30T14:45:00&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output should look like this…&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STDTC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ST_Y ST_M ST_D ST_TM&lt;/P&gt;
&lt;P&gt;2015-08-27T 8:36:00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2015&amp;nbsp; &amp;nbsp;8 &amp;nbsp;&amp;nbsp;27 &amp;nbsp;&amp;nbsp;08:36&lt;/P&gt;
&lt;P&gt;2014-09-30T14:45:00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2014 &amp;nbsp;9 &amp;nbsp;&amp;nbsp;&amp;nbsp;30 &amp;nbsp;&amp;nbsp;14:45&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rakesh&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 19:02:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-date-month-year-and-time-from-a-datetime-variable/m-p/252483#M268800</guid>
      <dc:creator>rakeshvvv</dc:creator>
      <dc:date>2016-02-25T19:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting date, month, year and time from a datetime variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-date-month-year-and-time-from-a-datetime-variable/m-p/252486#M268801</link>
      <description>&lt;P&gt;1. Datepart() function to extract date&lt;/P&gt;
&lt;P&gt;2. Timepart() function to extract time&lt;/P&gt;
&lt;P&gt;3. Year(), Month(), Day() function to extract date components - reference variable from #1&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 19:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-date-month-year-and-time-from-a-datetime-variable/m-p/252486#M268801</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-25T19:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting date, month, year and time from a datetime variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-date-month-year-and-time-from-a-datetime-variable/m-p/252518#M268802</link>
      <description>&lt;P&gt;Hi mate,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this. Not the best option but works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dt;
  date="2015-08-27T 8:36:00 ";
run;

data dt2;
   set dt;
   ST_Y  = input(scan(date,1,"-"),Year.);
   ST_M  = input(scan(date,2,"-"),month.);
   ST_D  = input(scan(scan(date,1,"T"),3,"-"),day.);
   ST_TM = input(scan(date,2,"T"),nltime10.);
   format ST_TM nltime10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 19:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-date-month-year-and-time-from-a-datetime-variable/m-p/252518#M268802</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2016-02-25T19:45:36Z</dc:date>
    </item>
  </channel>
</rss>

