Financial Toolbox
  Go to function:
    Search    Help Desk 
datenum    Examples   See Also

Create date number.

Syntax

Description

n = datenum(ds) returns a serial date number n given a date string ds. Date numbers are the number of days that has passed since a base date. In MATLAB, date number 1 is January 1, 0000 A.D. If the input includes time components, the date number includes a fractional component. If the input is only a time component, the date number is only a fractional time component.

The date string ds can be any of several forms:

Date strings with two-character years, e.g., 12-june-12, are assumed to lie within the 100-year period centered about the current year.

n = datenum(ds,p) assumes that two-character years lie within the 100-year period beginning with the pivot year p . The default pivot year is the current year minus 50 years.

n = datenum(y, mo, d) returns a serial date number n given year, month, and day integers y, mo, and d.

n = datenum(y, mo, d, h, mi, s) returns a serial date number n given year, month, day, hour, minute, and second integers y, mo, d, h, mi, and s.

n = datenum(dn) returns a serial date number n given a serial date number dn.

Note:
This function now ships with basic MATLAB. It originally shipped only with the Financial Toolbox, and this description remains here for your convenience.

Examples

The next example demonstrates the use of the pivot year in interpreting date strings with two-character years.

See Also

datestr, datevec, daysact, now, today



[ Previous | Help Desk | Next ]