DATDIF Function

Returns the number of days between two dates after computing the difference between the dates according to specified day count conventions.

Category: Date and Time

Syntax

DATDIF(sdate,edate,basis)

Required Arguments

sdate

specifies a SAS date value that identifies the starting date.

Tip If sdate falls at the end of a month, then SAS treats the date as if it were the last day of a 30-day month.

edate

specifies a SAS date value that identifies the ending date.

Tip If edate falls at the end of a month, then SAS treats the date as if it were the last day of a 30-day month.

basis

specifies a character string that represents the day count basis. The following values for basis are valid:

'30/360'

specifies a 30-day month and a 360-day year, regardless of the actual number of calendar days in a month or year.

A security that pays interest on the last day of a month will either always make its interest payments on the last day of the month, or it will always make its payments on the numerically same day of a month, unless that day is not a valid day of the month, such as February 30. For more information, see Method of Calculation for Day Count Basis (30/360) .
Alias '360'

'ACT/ACT'

uses the actual number of days between dates. Each month is considered to have the actual number of calendar days in that month, and each year is considered to have the actual number of calendar days in that year.

Alias 'Actual'

'ACT/360'

uses the actual number of calendar days in a particular month, and 360 days as the number of days in a year, regardless of the actual number of days in a year.

Tip ACT/360 is used for short-term securities.

'ACT/365'

uses the actual number of calendar days in a particular month, and 365 days as the number of days in a year, regardless of the actual number of days in a year.

Tip ACT/365 is used for short-term securities.

Details

The Basics

The DATDIF function has a specific meaning in the securities industry, and the method of calculation is not the same as the actual day count method. Calculations can use months and years that contain the actual number of days. Calculations can also be based on a 30-day month or a 360-day year. For more information about standard securities calculation methods, see the References section at the bottom of this function.
Note: When counting the number of days in a month, DATDIF always includes the starting date and excludes the ending date.

Method of Calculation for Day Count Basis (30/360)

To calculate the number of days between two dates, use the following formula:
N u m b e r o f d a y s = [ ( Y 2 - Y 1 ) * 3 6 0 ] + [ ( M 2 - M 1 ) * 3 0 ] + ( D 2 - D 1 )
Arguments
Y2
specifies the year of the later date.
Y1
specifies the year of the earlier date.
M2
specifies the month of the later date.
M1
specifies the month of the earlier date.
D2
specifies the day of the later date.
D1
specifies the day of the earlier date.
Because all months can contain only 30 days, you must adjust for the months that do not contain 30 days. Do this before you calculate the number of days between the two dates.
The following rules apply:
  • If the security follows the End-of-Month rule, and D2 is the last day of February (28 days in a non-leap year, 29 days in a leap year), and D1 is the last day of February, then change D2 to 30.
  • If the security follows the End-of-Month rule, and D1 is the last day of February, then change D1 to 30.
  • If the value of D2 is 31 and the value of D1 is 30 or 31, then change D2 to 30.
  • If the value of D1 is 31, then change D1 to 30.

Example

In the following example, DATDIF returns the actual number of days between two dates, as well as the number of days based on a 30-day month and a 360-day year.
data _null;
   sdate='16oct78'd;
   edate='16feb96'd;
   actual=datdif(sdate, edate, 'act/act');
   days360=datdif(sdate, edate, '30/360');
   put actual= days360=;
run;
SAS Statement
Result
put actual=;
6332
put days360=;
6240

See Also

Functions:

References

Securities Industry Association. 1994. Standard Securities Calculation Methods - Fixed Income Securities Formulas for Analytic Measures. Vol. 2. New York, USA: . Securities Industry Association