[CLOSED] Calculate DATEDIF based on a 360 day year
Is there a way to calculate the difference between 2 dates in days based on a 360 day year, similar to excel's days360 function?This message has been edited. Last edited by: Kerry,
Mainframe FOCUS 7.3.8 10.26.05 18.02 Windows, All Outputs
Basically it is saying WF doesn't have such a function; however, there is technique that may help you on that URL.
WF 7.6.10, Windows, PDF, Excel
October 13, 2011, 02:22 PM
Dan Satchell
There may be other solutions, but one is to multiply the number of days calculated with DATEDIF by 72/73 (which is the same as the number of minutes in a 360 day year divided by the number of minutes in a 365 day year: 1440 / 1460).
DEFINE FILE CAR
DATE1/YYMD WITH COUNTRY = '2010/01/01';
DATE2/YYMD WITH COUNTRY = '2010/02/01';
DATE3/YYMD WITH COUNTRY = '2011/01/01';
DATE_DIFF_365M/I5 = DATEDIF(DATE1,DATE2,'D');
DATE_DIFF_360M/I5 = DATE_DIFF_365M * 72 / 73 ;
DATE_DIFF_365Y/I5 = DATEDIF(DATE1,DATE3,'D');
DATE_DIFF_360Y/I5 = DATE_DIFF_365Y * 72 / 73 ;
END
-*
TABLE FILE CAR
PRINT
DATE1 DATE2
DATE_DIFF_365M DATE_DIFF_360M
DATE1 DATE3
DATE_DIFF_365Y DATE_DIFF_360Y
WHERE RECORDLIMIT EQ 1 ;
END
This message has been edited. Last edited by: Dan Satchell,
Just occurred to me that leap years could present a problem. May be best to calculate the number of days in the year and use that number as the divisor for converting to 360 day equivalents.
DEFINE FILE CAR
YEAR_BEG/YYMD WITH COUNTRY = '2008/01/01';
YEAR_END/YYMD WITH COUNTRY = '2008/12/31';
YEAR_DAYS/I5 = DATEDIF(YEAR_BEG,YEAR_END,'D') + 1 ;
DATE1/YYMD WITH COUNTRY = '2008/02/01';
DATE2/YYMD WITH COUNTRY = '2008/03/01';
DATE3/YYMD WITH COUNTRY = '2009/01/01';
DATE_DIFF_365M/I5 = DATEDIF(DATE1,DATE2,'D');
DATE_DIFF_360M/I5 = DATE_DIFF_365M * 360 / YEAR_DAYS ;
DATE_DIFF_365Y/I5 = DATEDIF(YEAR_BEG,DATE3,'D');
DATE_DIFF_360Y/I5 = DATE_DIFF_365Y * 360 / YEAR_DAYS ;
END
-*
TABLE FILE CAR
PRINT
YEAR_BEG YEAR_DAYS
DATE1 DATE2
DATE_DIFF_365M DATE_DIFF_360M
DATE3
DATE_DIFF_365Y DATE_DIFF_360Y
WHERE RECORDLIMIT EQ 1 ;
END
WebFOCUS 7.7.05
October 13, 2011, 04:49 PM
njsden
quote:
DATEDIF(DATE1,DATE2,'D') * 360 / 365 ;
Could the leap year issue be solved by slightly adjusting your original expression?