daysact

Actual number of days between dates

Syntax

NumDays = daysact(StartDate, EndDate)

Arguments

StartDate

Enter as serial date numbers or date strings.

EndDate

(Optional) Enter as serial date numbers or date strings.

Either input can contain multiple values, but if so, the other must contain the same number of values or a single value that applies to all. For example, if StartDate is an n-row character array of date strings, then EndDate must be an n-row character array of date strings or a single date. NumDays is then an n-by-1 vector of numbers.

Description

NumDays = daysact(StartDate, EndDate) returns the actual number of days between two dates. Enter dates as serial date numbers or date strings. NumDays is negative if EndDate is earlier than StartDate.

NumDays = daysact(StartDate) returns the actual number of days between the MATLAB® base date and StartDate. In MATLAB software, the base date 1 is 1-Jan-0000 A.D. See datenum for a similar function.

Examples

NumDays = daysact('7-sep-2002',  '25-dec-2002')
NumDays =
   109
NumDays = daysact('9/7/2002')
NumDays =
      731466
MoreDays = ['09/07/2002'; '10/22/2002'; '11/05/2002'];
NumDays = daysact(MoreDays, '12/25/2002')
NumDays =
   109
    64
    50
Was this topic helpful?