<?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: Changing the Format of a Date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Changing-the-Format-of-a-Date/m-p/672991#M202343</link>
    <description>&lt;P&gt;Here is an example of calculating the number of months between two datetimes. I suspect you will want to count contiguous months rather than month boundaries, hence the "C" option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   months=intck('dtmonth', '01aug2011:00:10:48'dt, '01feb2012:00:10:48'dt, 'C');
   put months=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Read the documentation&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1md4mx2crzfaqn14va8kt7qvfhr.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jul 2020 21:48:15 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2020-07-28T21:48:15Z</dc:date>
    <item>
      <title>Changing the Format of a Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-the-Format-of-a-Date/m-p/672984#M202336</link>
      <description>&lt;P&gt;It is extremely frustrating going from one date format to another.&amp;nbsp; It feels like each time I'm using a date function, it calls for something different.&amp;nbsp; What is the inner logic that governs all these different SAS date formats.&amp;nbsp; All I want to do is to take the difference in months between two dates.&amp;nbsp; Apparently, INTNX only accepts something like ' 05JAN2014'd.&amp;nbsp; So how do I convert 05JAN2014:00:00:00 into the required format?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 21:30:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-the-Format-of-a-Date/m-p/672984#M202336</guid>
      <dc:creator>AndyTam</dc:creator>
      <dc:date>2020-07-28T21:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Changing the Format of a Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-the-Format-of-a-Date/m-p/672987#M202339</link>
      <description>&lt;P&gt;INTNX and INTCK accepts dates or date/time values. '05JAN2014'd is a date value. '05JAN2014:00:00:00'dt is a datetime value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To determine the difference in months from date values, use INTCK('month',date1,date2) &lt;EM&gt;(note: both variables must contain date values)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To determine the difference in months from datetime values, use INTCK('dtmonth',datetime1,datetime2) &lt;EM&gt;(note: both variables must contain datetime values)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can convert datetime values to date values using the DATEPART() function.&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 21:43:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-the-Format-of-a-Date/m-p/672987#M202339</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-28T21:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Changing the Format of a Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-the-Format-of-a-Date/m-p/672989#M202341</link>
      <description>&lt;P&gt;Internally, dates are counts of days, and datetimes and times counts of seconds.&lt;/P&gt;
&lt;P&gt;Formats are only there to control how those values are displayed.&lt;/P&gt;
&lt;P&gt;To compare values, you must make them comparable. You can't compare a date with a datetime.&lt;/P&gt;
&lt;P&gt;Intervals between two values are calculated with the INTCK function; with dates, you use the interval 'month', with datetimes 'dtmonth'.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 21:45:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-the-Format-of-a-Date/m-p/672989#M202341</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-28T21:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: Changing the Format of a Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-the-Format-of-a-Date/m-p/672990#M202342</link>
      <description>&lt;P&gt;Ok, but how do I convert the column, called IncidentDate, of date-time values into 'xxxxxx'.dt?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 21:46:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-the-Format-of-a-Date/m-p/672990#M202342</guid>
      <dc:creator>AndyTam</dc:creator>
      <dc:date>2020-07-28T21:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: Changing the Format of a Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-the-Format-of-a-Date/m-p/672991#M202343</link>
      <description>&lt;P&gt;Here is an example of calculating the number of months between two datetimes. I suspect you will want to count contiguous months rather than month boundaries, hence the "C" option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   months=intck('dtmonth', '01aug2011:00:10:48'dt, '01feb2012:00:10:48'dt, 'C');
   put months=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Read the documentation&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1md4mx2crzfaqn14va8kt7qvfhr.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 21:48:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-the-Format-of-a-Date/m-p/672991#M202343</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-07-28T21:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: Changing the Format of a Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-the-Format-of-a-Date/m-p/672992#M202344</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327836"&gt;@AndyTam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Ok, but how do I convert the column, called IncidentDate, of date-time values into 'xxxxxx'.dt?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You don't. If IncidentDate contains datetime values, then there's no reason to "convert" it into 'xxxxx'.dt which is also a datetime value.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 21:50:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-the-Format-of-a-Date/m-p/672992#M202344</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-28T21:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Changing the Format of a Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-the-Format-of-a-Date/m-p/672994#M202346</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327836"&gt;@AndyTam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Ok, but how do I convert the column, called IncidentDate, of date-time values into 'xxxxxx'.dt?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You don't need to, you just use the value. As already stated, internally it is a count of seconds, and that's what the functions expect, if used with the 'dt'-type date and the time intervals.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 21:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-the-Format-of-a-Date/m-p/672994#M202346</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-28T21:55:45Z</dc:date>
    </item>
  </channel>
</rss>

