Financial Toolbox    
datenum

Create date number

Syntax

Description

DateNumber = datenum(DateString) returns a serial date number given a date string. 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 can be any of several forms.

Unless you specify a pivot year, 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.

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

DateNumber = datenum(Year, Month, Day) returns a serial date number given year, month, and day integers.

DateNumber = datenum(Year, Month, Day, Hour, Minute, Second) returns a serial date number given year, month, day, hour, minute, and second integers.

Examples

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

See Also

datedisp, datestr, datevec, daysact, now, today


  datemnth datestr