<?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: exact date difference in months in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42902#M8769</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bad specification. You should argue against it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0.5 month in February is 14 days typically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0.5 of December is 15.5 days. 1.5 days/30 days = 5% error introduced for no reason.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use 365.25/12 = 30.4375 days as a month and calculate the difference as days and then divide by 30.4375 to get a slightly better definition.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Apr 2014 22:41:54 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2014-04-16T22:41:54Z</dc:date>
    <item>
      <title>exact date difference in months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42895#M8762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have two dates and I need difference in months (exact). &lt;BR /&gt;I found inck function, but it always rounds result on whole months. I need output as decimal number, for example 8.214 months. How to do this? Is there any function ot his purpose?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can calculate difference in days and divide it by (30 ? 31), but the result would not be exact and i do not treat this as clean solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for an answer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2011 13:17:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42895#M8762</guid>
      <dc:creator>Julo</dc:creator>
      <dc:date>2011-08-04T13:17:40Z</dc:date>
    </item>
    <item>
      <title>exact date difference in months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42896#M8763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi julo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do you want to calculate the decimal point in months. Is it no of days/30 0r no of days/31. An example would be helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2011 13:33:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42896#M8763</guid>
      <dc:creator>manojinpec</dc:creator>
      <dc:date>2011-08-04T13:33:13Z</dc:date>
    </item>
    <item>
      <title>exact date difference in months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42897#M8764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;that's the question, I would say that there would be some ISO standard about this, but i don't know.... do you?&lt;/P&gt;&lt;P&gt;Now I solve it that I divide number of days by (365.25/12).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;J.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2011 13:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42897#M8764</guid>
      <dc:creator>Julo</dc:creator>
      <dc:date>2011-08-04T13:43:09Z</dc:date>
    </item>
    <item>
      <title>exact date difference in months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42898#M8765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not aware of any standard way of doing this, and I'd be interested to understand why you want to see months in this way as I can't think off-hand of a reason for using this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, maybe something like the below will help.&amp;nbsp; The variable month3 is a single-line version of the rest, which I left in to help make the calculation more clear.&amp;nbsp; Presumably it could be tidied up a bit more...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;format date1 date9.;&lt;/P&gt;&lt;P&gt;format date2 date9.;&lt;/P&gt;&lt;P&gt;date1 = '09FEB2011'd;&lt;/P&gt;&lt;P&gt;do i = -60 to 60 by 5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date2 = intnx('day',date1,i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;months = intck('month',date1,date2);&lt;/P&gt;&lt;P&gt;temp = intnx('month',date1,months,'sameday');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;days_shift = intck('day',temp,date2);&lt;/P&gt;&lt;P&gt;days_in_month = day(intnx('month',date2,0,'end'));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;month2 = months + days_shift/days_in_month;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;month3 = intck('month',date1,date2) + intck('day', intnx('month',date1,intck('month',date1,date2),'sameday'),date2) / day(intnx('month',date2,0,'end'));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To look at an example then (UK dates):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Date1: 09/02/2011&lt;/P&gt;&lt;P&gt;Date2: 06/03/2011&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using intck will say there is 1 month interval between the two, so Month = 1;&lt;/P&gt;&lt;P&gt;Temp is set to Date1 + Month, but to the same day, hence Temp = 09/03/2011.&lt;/P&gt;&lt;P&gt;There are -3 days between Temp and Date2, hence Days_Shift = -3.&lt;/P&gt;&lt;P&gt;There are 31 days in March, therefore Days_in_Month = 31.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Adding this together then says 1 full month, minus 3 days (which we take as the fraction 3 / 31), which is 28 / 31 or 0.9032 months.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The fraction element is determined by the number of days in the month of Date2, and it should work regardless as to which date is greater.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2011 15:46:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42898#M8765</guid>
      <dc:creator>DF</dc:creator>
      <dc:date>2011-08-04T15:46:23Z</dc:date>
    </item>
    <item>
      <title>exact date difference in months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42899#M8766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The reason why is specification which I have to implement. There are intervals in months.&lt;/P&gt;&lt;P&gt;Thanx for example.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2011 08:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42899#M8766</guid>
      <dc:creator>Julo</dc:creator>
      <dc:date>2011-08-05T08:09:08Z</dc:date>
    </item>
    <item>
      <title>exact date difference in months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42900#M8767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Julo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the exact number of months between 1-Jan and 31-Jan ?&lt;/P&gt;&lt;P&gt;What is an exact difference in months between two dates which fall on different days in the month?&lt;/P&gt;&lt;P&gt;Will it be fractional?&lt;/P&gt;&lt;P&gt;What should the fraction be when the startmonth has a different number of days from the finishing month?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sounds like an incomplete spec&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;best of luck&lt;/P&gt;&lt;P&gt;peterC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2011 22:25:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42900#M8767</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-08-10T22:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: exact date difference in months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42901#M8768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;EM&gt;Try this:&lt;/EM&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;enddate1=intnx('month',date1,0,'end');&lt;/STRONG&gt; /*end date of date1 ? 30/31/28/29*/&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;enddate2=intnx('month',date2,0,'end');&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;format enddate1 enddate2 date9.;&lt;/STRONG&gt; /*ddmmmyyyy*/&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;numdays1=day(enddate1); &lt;/STRONG&gt;/*number of max days in that month*/&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;numdays2=day(enddate2);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Months = (datdif (date1,enddate1, 'act/act')/numdays1 )&lt;/STRONG&gt; + &lt;STRONG&gt; intck('month',date1,date2)&lt;/STRONG&gt;&amp;nbsp; +&amp;nbsp; &lt;STRONG&gt;(day(date2)/numdays2) &lt;/STRONG&gt;-&lt;STRONG&gt;1&lt;/STRONG&gt;; /* due to the limitation of intck function a -1 is adjusted*/&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;/*date1- date2*/&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;/*date1month+ date2month +and all months in between*/&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="text-decoration: underline;"&gt;Example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;5feb2014 - 17may2014&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;5feb-28feb/28&amp;nbsp; + 2+17may-1may/31&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Cheers!&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Apr 2014 19:08:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42901#M8768</guid>
      <dc:creator>JVarghese</dc:creator>
      <dc:date>2014-04-16T19:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: exact date difference in months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42902#M8769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bad specification. You should argue against it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0.5 month in February is 14 days typically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0.5 of December is 15.5 days. 1.5 days/30 days = 5% error introduced for no reason.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use 365.25/12 = 30.4375 days as a month and calculate the difference as days and then divide by 30.4375 to get a slightly better definition.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Apr 2014 22:41:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42902#M8769</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-04-16T22:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: exact date difference in months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42903#M8770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Guys;&lt;/P&gt;&lt;P&gt;please note that the question was asked about 3 years back and probably he might have fixed it and who knows.&lt;/P&gt;&lt;P&gt;Let's wait for his response to find what step he took. What do you say?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Apr 2014 00:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42903#M8770</guid>
      <dc:creator>JVarghese</dc:creator>
      <dc:date>2014-04-17T00:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: exact date difference in months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42904#M8771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Out of curiosity why did you restart a 3 year old thread?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Apr 2014 04:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42904#M8771</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-04-17T04:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: exact date difference in months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42905#M8772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt; n=yrdif('02jan2013'd,'12aug2013'd,'act/act')*12 ;&lt;/P&gt;&lt;P&gt; put n= ;&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Apr 2014 05:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42905#M8772</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-04-17T05:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: exact date difference in months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42906#M8773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Exactly, just out of curiosity:) .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Apr 2014 16:19:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/exact-date-difference-in-months/m-p/42906#M8773</guid>
      <dc:creator>JVarghese</dc:creator>
      <dc:date>2014-04-17T16:19:37Z</dc:date>
    </item>
  </channel>
</rss>

