| MATLAB Function Reference | Search  Help Desk |
| datevec | Examples See Also |
C = datevec(A) C = datevec(A,P) [Y,M,D,H,MI,S] = datevec(A)
Description
C = datevec(A)
splits its input into an n-by-6 array with each row containing the vector [Y,M,D,H,MI,S]. The first five date vector elements are integers. Input A can either consist of strings of the sort produced by the datestr function, or scalars of the sort produced by the datenum and now functions. 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.
C = datevec(A,P)
assumes that two-character years lie within the 100-yearperiod beginning with the pivot year p. The default pivot year is the current year minus 50 years..
[Y,M,D,H,MI,S] = datevec(A)
returns the components of the date vector as individual variables.
When creating your own date vector, you need not make the components integers. Any components that lie outside their conventional ranges affect the next higher component (so that, for instance, the anomalous June 31 becomes July 1). A zeroth month, with zero days, is allowed.
Examples
datevec('12/24/1984')
ans =
1984 12 24 0 0 0
t = '725000.00',
Then datevec(d) and datevec(t) generate [1984 12 24 0 0 0].
See Also
clock, datenum, datestr