| Financial Toolbox | ![]() |
Syntax
DateVector = datevec(Date) DateVector = datevec(Date, Pivot) [Year, Month, Day, Hour, Minute, Second] = datevec(Date)
Description
DateVector = datevec(Date) converts a date number or a date string to a date vector whose elements are [
Year Month Day Hour Minute Second]. The first five elements are integers, the sixth is a floating-point number. 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.
DateVector = datevec(Date, 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.
| Note MATLAB's internal date handling and calculations generate no ambiguous values. However, whenever possible, programmers should use date strings containing four-digit years or serial date numbers. |
[Year, Month, Day, Hour, Minute, Second] = datevec(Date)
converts a date number or a date string to a date vector and returns the components of the date vector as individual variables.
| Note This function now ships with basic MATLAB. It originally shipped only with the Financial Toolbox. This description remains here for your convenience. |
Examples
DateVec = datevec('28-Jul-00') DateVec = 2000 7 28 0 0 0 DateVec = datevec(730695) DateVec = 2000 7 28 0 0 0 DateVec = datevec(730695.776) DateVec = 2000 7 28 18 37 26.4 [Year, Month, Day, Hour, Minute, Second] = datevec(730695.776) Year = 2000 Month = 7 Day = 28 Hour = 18 Minute = 37 Second = 26.4 [Year, Month, Day] = datevec(730695:730697) Year = 2000 2000 2000 Month = 7 7 7 Day = 28 29 30
See Also
| datestr | datewrkdy | ![]() |