datevec
Splits dates into year, month, day, hour, minute and second.
Category: Language Fundamentals > Data Types
Syntax
V = datevec(D)
Returns a matrix with one date vector per row.
[y, m, d, h, mi, s] = datevec(D)
Returns each component separately.
Description
datevec is the inverse of datenum for values in range. The seconds column holds the fractional part of the minute. Text input is recognized in common layouts such as '2020-03-04 05:06:07' or '03/04/2020'.
Input arguments
D- Date number, date text or datetime.
Output arguments
VN-by-6 matrix[y m d h mi s].y, m, d, ...- Column vectors with each component.
Example
From text and number
datevec('2020-03-04 05:06:07')
[y, m, d] = datevec(738000)
Output
ans = 1×6
2020 3 4 5 6 7
y = 2020
m = 7
d = 28