<?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: formated date display in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/formated-date-display/m-p/386242#M92473</link>
    <description>&lt;P&gt;Most likely your variable does not contain date value, but nstead if contains datetime values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use the DTDATE format to display just the date part of the datetime values.&lt;/P&gt;
&lt;P&gt;Also you need to use a datetime literal instead of a date literal in the WHERE clause.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table InstallDate as
  SELECT FLT.vehicle_header
       , FLT.vehicle_no
       , FLT.occur_date
       , FLT.FAULT_CODE
       , FLT.FAULT_DESCRIPTION
       , min(FLT.occur_date) as sw_install_date format dtdate9.
  FROM RMDEOAP.GETS_DW_EOA_FAULTS FLT
  WHERE FLT.vehicle_header = 'NS'
    and FLT.occur_date between '25Jul2017:00:00'dt and datetime()
  group by FLT.vehicle_no
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 08 Aug 2017 13:03:02 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-08-08T13:03:02Z</dc:date>
    <item>
      <title>formated date display</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formated-date-display/m-p/386236#M92471</link>
      <description>&lt;P&gt;I'm attempting to get a standard date display and the following code generates asterisks for sw_install_date:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table InstallDate as
		SELECT
			FLT.vehicle_header,
			FLT.vehicle_no,
			FLT.occur_date,
			FLT.FAULT_CODE,
			FLT.FAULT_DESCRIPTION,
			min(FLT.occur_date) as sw_install_date format date9.
		FROM RMDEOAP.GETS_DW_EOA_FAULTS FLT
			WHERE 
				FLT.vehicle_header = 'NS' and
	FLT.occur_date between '25Jul2017'd and datetime()
	group by FLT.vehicle_no
	;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Something is wrong with the way I've used the 'format' statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sw_install_date.JPG" style="width: 131px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14373i1DD50407DB06664E/image-size/large?v=v2&amp;amp;px=999" role="button" title="sw_install_date.JPG" alt="sw_install_date.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 12:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formated-date-display/m-p/386236#M92471</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2017-08-08T12:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: formated date display</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formated-date-display/m-p/386241#M92472</link>
      <description>&lt;P&gt;Your mixing up dates and date times, each of these is a very different number and your where clause is invalid as well:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;FLT&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;occur_date between &lt;SPAN class="token datetime number"&gt;'25Jul2017'd&lt;/SPAN&gt; and &lt;SPAN class="token function"&gt;datetime&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;If FLT.OCCUR_DATE is a date variable, then the numeric of that will be comparable to '25Jul2017'd, however it will not be comparable to datetime(). &amp;nbsp;Likewise if OCCUR_DATE is a datetime value then it will not be comparable to '25jul2017'd.&lt;/P&gt;
&lt;P&gt;Judging by the screenshot you OCCUR_DATE is a DATETIME variable, hence you need to either datepart or format correctly:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table INSTALLDATE as
  select  FLT.VEHICLE_HEADER,
    	  FLT.VEHICLE_NO,
    	  FLT.OCCUR_DATE,
    	  FLT.FAULT_CODE,
    	  FLT.FAULT_DESCRIPTION,
    	  datepart(min(FLT.OCCUR_DATE)) as SW_INSTALL_DATE format date9.
  from    RMDEOAP.GETS_DW_EOA_FAULTS FLT&lt;BR /&gt;  where   FLT.VEHICLE_HEADER='NS'
    and   datepart(FLT.OCCUR_DATE) between '25Jul2017'd and date()
  group by FLT.VEHICLE_NO;
quit&lt;/PRE&gt;
&lt;P&gt;This uses only the datepart of the datetime in all cases.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 13:02:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formated-date-display/m-p/386241#M92472</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-08T13:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: formated date display</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formated-date-display/m-p/386242#M92473</link>
      <description>&lt;P&gt;Most likely your variable does not contain date value, but nstead if contains datetime values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use the DTDATE format to display just the date part of the datetime values.&lt;/P&gt;
&lt;P&gt;Also you need to use a datetime literal instead of a date literal in the WHERE clause.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table InstallDate as
  SELECT FLT.vehicle_header
       , FLT.vehicle_no
       , FLT.occur_date
       , FLT.FAULT_CODE
       , FLT.FAULT_DESCRIPTION
       , min(FLT.occur_date) as sw_install_date format dtdate9.
  FROM RMDEOAP.GETS_DW_EOA_FAULTS FLT
  WHERE FLT.vehicle_header = 'NS'
    and FLT.occur_date between '25Jul2017:00:00'dt and datetime()
  group by FLT.vehicle_no
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2017 13:03:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formated-date-display/m-p/386242#M92473</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-08-08T13:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: formated date display</title>
      <link>https://communities.sas.com/t5/SAS-Programming/formated-date-display/m-p/386249#M92475</link>
      <description>&lt;P&gt;Thanks. This works well.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 13:25:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/formated-date-display/m-p/386249#M92475</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2017-08-08T13:25:31Z</dc:date>
    </item>
  </channel>
</rss>

