Calculate number of months between 2 dates
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | * Calculate # months between 2 dates. * rlevesque@videotron.ca. data list / date1 1-8 (ADATE) date2 10-17 (ADATE) . begin data 01/20/98 01/28/99 01/20/98 01/18/99 02/20/96 02/18/99 02/01/90 04/10/95 10/03/99 11/01/00 end data. COMPUTE nb_mths1 = (XDATE.YEAR(date2) -XDATE.YEAR(date1))*12+XDATE.MONTH(date2)-XDATE.MONTH(date1). COMPUTE nb_mths2 = nb_mths1 -(XDATE.MDAY(date2) < XDATE.MDAY(date1)). * nb_mths2 adjusts for incomplete months. EXECUTE. |
Related pages
...