Previous Page | Next Page

Functions and CALL Routines

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
Arguments
Details
The Basics
Method of Calculation for Day Count Basis (30/360)
Examples
See Also
References

Syntax

DATDIF(sdate,edate,basis)


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 References.

Note:   When counting the number of days in a month, DATDIF always includes the starting date and excludes the ending date.  [cautionend]


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

To calculate the number of days between two dates, use the following formula:

[equation]

where

Y2

specifies the year of the later date.

Y1

specifies the year of the earllier 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:


Examples

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 Statements Results
put actual=;
6332
put days360=;
6240


See Also

Functions:

YRDIF Function


References

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

Previous Page | Next Page | Top of Page