<?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: Date formatting in a where statement in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-formatting-in-a-where-statement/m-p/420518#M27036</link>
    <description>&lt;P&gt;The example value you show is a datetime which uses seconds for measure, dates use days, so the comparison doesn't quite work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where datepart(date) &amp;gt;= '01JAN2017'd&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the function datepart extracts the date portion of the datetime value for use with date comparisons or date functions.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Dec 2017 16:44:13 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-12-12T16:44:13Z</dc:date>
    <item>
      <title>Date formatting in a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-formatting-in-a-where-statement/m-p/420516#M27034</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'mt rying to select a date range from a table that currently has dates in the format: &lt;STRONG&gt;18NOV2016:14:31:52.000000&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried using &lt;STRONG&gt;where date &amp;gt;= '01JAN2017'd.&lt;/STRONG&gt;&amp;nbsp;However, , my result still show records with dates in prior years.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 16:40:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-formatting-in-a-where-statement/m-p/420516#M27034</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2017-12-12T16:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Date formatting in a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-formatting-in-a-where-statement/m-p/420517#M27035</link>
      <description>&lt;P&gt;That's a datetime not a date.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use DATEPART() to obtain the date portion or use DHMS() to create a datetime variable with the date you're using.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;where datepart(date) &amp;gt;= '01JAN2017'd&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;where date &amp;gt;= dhms( '01JAN2017'd, 0, 0, 0)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 16:43:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-formatting-in-a-where-statement/m-p/420517#M27035</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-12T16:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: Date formatting in a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-formatting-in-a-where-statement/m-p/420518#M27036</link>
      <description>&lt;P&gt;The example value you show is a datetime which uses seconds for measure, dates use days, so the comparison doesn't quite work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where datepart(date) &amp;gt;= '01JAN2017'd&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the function datepart extracts the date portion of the datetime value for use with date comparisons or date functions.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 16:44:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-formatting-in-a-where-statement/m-p/420518#M27036</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-12T16:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: Date formatting in a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-formatting-in-a-where-statement/m-p/420523#M27038</link>
      <description>&lt;P&gt;When you ask it to keep datetime values that are after about 6 am on January 1st, 1960 then you are very likely to find values that are before January 2017.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; 56         data _null_;
 57           do num = '18NOV2016:14:31:52.000000'dt , '01JAN2017'd ;
 58             put / num= ;
 59             length format $20 value $32 ;
 60             do format='comma32.','date11.','datetime20.' ;
 61               value=putn(num,format);
 62               put format $20. +1 value ;
 63             end;
 64           end;
 65         run;
 
 num=1795098712
 comma32.             1,795,098,712
 date11.              ***********
 datetime20.          18NOV2016:14:31:52
 num=20820
 comma32.             20,820
 date11.              01-JAN-2017
 datetime20.          01JAN1960:05:47:00&lt;/PRE&gt;
&lt;P&gt;Use a datetime literal to test datetime values.&amp;nbsp; Or convert the values to dates if you want to compare to dates.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where datepart(date) &amp;gt;= '01JAN2017'd ;
where date &amp;gt;= '01JAN2017:00:00'dt ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Dec 2017 17:03:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-formatting-in-a-where-statement/m-p/420523#M27038</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-12-12T17:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Date formatting in a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-formatting-in-a-where-statement/m-p/420527#M27040</link>
      <description>&lt;P&gt;Perfect! thank you&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 17:10:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Date-formatting-in-a-where-statement/m-p/420527#M27040</guid>
      <dc:creator>Dogo23</dc:creator>
      <dc:date>2017-12-12T17:10:43Z</dc:date>
    </item>
  </channel>
</rss>

