| Financial Toolbox | Search  Help Desk |
| datevec | Examples See Also |
Syntax
dv = datevec(d) dv = datevec(d, p) [y, mo, d, h, mi, s] = datevec(d)
Description
dv = datevec(d)
converts a date number or a date string d to a date vector dv 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.
dv = datevec(d, 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.
[y, mo, d, h, mi, s] = datevec(d)
converts a date number or a date string d to a date vector and returns the components of the date vector as individual variables y year, mo month, d day, h hour, mi minute, and s second.
Note:
Examples
dv=datevec('19-may-1995')
dv =
1995 5 19 0 0 0
dv=datevec(728798)
dv =
1995 5 19 0 0 0
dv=datevec(728798.776)
dv =
1995 5 19 18 37 26.4
[y, mo, d, h, mi, s] = datevec(728798.776)
y =
1995
mo =
5
d =
19
h =
18
mi =
37
s =
26.4
[y, mo, d] = datevec(728798:728800)
y =
1995 1995 1995
mo =
5 5 5
d =
19 20 21
See Also
datenum, datestr, now, today