<?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 datepart function doesn't return the datepart in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/datepart-function-doesn-t-return-the-datepart/m-p/827692#M326947</link>
    <description>&lt;P&gt;Hello team,&lt;/P&gt;
&lt;P&gt;I have a dateTime as numeric as 06oct22:10:03, when I put datepart function to get the datepart of the variable, the time function still exists in the reuslt.&lt;/P&gt;
&lt;P&gt;Date1 = put(datepart(date2,date9.)&lt;/P&gt;
&lt;P&gt;Can someone help me with this?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;blue blue&lt;/P&gt;</description>
    <pubDate>Mon, 08 Aug 2022 19:25:22 GMT</pubDate>
    <dc:creator>GN0001</dc:creator>
    <dc:date>2022-08-08T19:25:22Z</dc:date>
    <item>
      <title>datepart function doesn't return the datepart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datepart-function-doesn-t-return-the-datepart/m-p/827692#M326947</link>
      <description>&lt;P&gt;Hello team,&lt;/P&gt;
&lt;P&gt;I have a dateTime as numeric as 06oct22:10:03, when I put datepart function to get the datepart of the variable, the time function still exists in the reuslt.&lt;/P&gt;
&lt;P&gt;Date1 = put(datepart(date2,date9.)&lt;/P&gt;
&lt;P&gt;Can someone help me with this?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;blue blue&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2022 19:25:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datepart-function-doesn-t-return-the-datepart/m-p/827692#M326947</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2022-08-08T19:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: datepart function doesn't return the datepart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datepart-function-doesn-t-return-the-datepart/m-p/827694#M326948</link>
      <description>&lt;P&gt;LOG. Read it.&lt;/P&gt;
&lt;P&gt;If you actually submit that code you are missing a )&lt;/P&gt;
&lt;PRE&gt;40   data example;
41     x='06oct22:10:03'dt;
42     y=put(datepart(x,date9.);
                        ------
                        386
                        76
ERROR 386-185: Expecting an arithmetic expression.

ERROR 76-322: Syntax error, statement will be ignored.

43   run;

&lt;/PRE&gt;
&lt;P&gt;Should be:&lt;/P&gt;
&lt;PRE&gt;44   data example;
45     x='06oct22:10:03'dt;
46     y=put(datepart(x),date9.);
47   run;
&lt;/PRE&gt;
&lt;P&gt;The result is 06OCT2022.&lt;/P&gt;
&lt;P&gt;Or use a different FORMAT:&lt;/P&gt;
&lt;PRE&gt;data example;
  x='06oct22:10:03'dt;
  y=put(x,dtdate9.);
run;&lt;/PRE&gt;
&lt;P&gt;The DTDATE format displays a datetime with just the DATE9 equivalent portion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if your code isn't working you either have an issue with the values, the syntax or possibly both.&lt;/P&gt;
&lt;P&gt;Although I question a need for that creation of a character value for dates. They don't sort well, at least not in Date9 format, cause extra work if you need to compare to an actual date value elsewhere, cannot be used in any of the date functions like Intnx or Intck, use formats to modify group creation for analysis, reporting or graphing.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2022 19:50:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datepart-function-doesn-t-return-the-datepart/m-p/827694#M326948</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-08-08T19:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: datepart function doesn't return the datepart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datepart-function-doesn-t-return-the-datepart/m-p/827722#M326959</link>
      <description>&lt;P&gt;Show us the&amp;nbsp;&lt;EM&gt;complete&lt;/EM&gt; log of the step where this seems to happen.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2022 21:54:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datepart-function-doesn-t-return-the-datepart/m-p/827722#M326959</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-08-08T21:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: datepart function doesn't return the datepart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/datepart-function-doesn-t-return-the-datepart/m-p/828393#M327238</link>
      <description>Hello team, I have not tested it. Please give me some time to test it. Blue berry</description>
      <pubDate>Fri, 12 Aug 2022 00:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/datepart-function-doesn-t-return-the-datepart/m-p/828393#M327238</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2022-08-12T00:35:01Z</dc:date>
    </item>
  </channel>
</rss>

