The IS8601_CONVERT call routine converts an ISO 8601 interval to datetime and duration values, or converts datetime and duration values to an ISO 8601 interval. When the IS8601_CONVERT call routine computes a duration from two SAS datetime values, the computation might not be correct when the dates are not in consecutive months. The computation is correct when dates are in consecutive months.
The sample code below illustrates the problem. The IS8601_CONVERT call routine can convert two SAS datetime values to a duration. The Start and End variables represent date values. Since we need SAS datetime values for the IS8601_CONVERT call routine parameters, Start and End values are read with the E8601DNw. informat to create SAS datetime values. An explanation of the parameters to the call routine follows:
The duration value that is calculated is not in a readable format, so it needs to be formatted with the $N8601E format.
data _null_;
length _aedur $32.;
start = '2017-10-04';
startn = input(start,E8601DN. );
end = '2017-12-01';
endn = input(end,E8601DN. );
CALL IS8601_CONVERT( 'dt/dt', 'du', startn, endn , _aedur);
_aedur = put(_aedur,$N8601E.);
put _aedur;
run;
The PUT statement writes this to the SAS log.
The incorrect computed value is P1M28D. The correct value should be P1M27D.
There is currently no circumvention for this issue.