Convert date and time to serial date number
Note
While serial date numbers can represent dates and times,
it is recommended that you use datetime
values to represent points in
time, and duration
or calendarDuration
values to represent
elapsed times.
converts the DateNumber
= datenum(t
)datetime
or
duration
values in the input array
t
to serial date numbers.
A serial date number represents the whole and fractional number of days from a fixed, preset date (January 0, 0000) in the proleptic ISO calendar.
converts text representing dates and times to serial date numbers.
If the format used in the text is known, specify the format as DateNumber
= datenum(DateString
)formatIn
.
Syntaxes without formatIn
are significantly slower
than syntaxes that include it.
uses DateNumber
= datenum(DateString
,formatIn
)formatIn
to
interpret the dates and times represented by DateString
.
uses DateNumber
= datenum(DateString
,PivotYear
)PivotYear
to
interpret text that specifies the year as two characters. If the format
used in the text is known, specify the format as formatIn
.
Syntaxes without formatIn
are significantly slower
than syntaxes that include it.
uses DateNumber
= datenum(DateString
,formatIn
,PivotYear
)formatIn
to
interpret the dates and times represented by DateString
,
and PivotYear
to interpret text that specifies
the year as two characters. You can specify formatIn
and PivotYear
in
either order.
converts
date vectors to serial date numbers, and returns a column vector of DateNumber
= datenum(DateVector
)m
date
numbers, where m
is the total number of date vectors
in DateVector
.
returns
the serial date numbers for corresponding elements of the DateNumber
= datenum(Y,M,D
)Y
, M
,
and D
(year, month, day) arrays. The arrays must
be of the same size (or any can be a scalar). You also can specify
the input arguments as a date vector, [Y,M,D]
.
additionally
returns the serial date numbers for corresponding elements of the DateNumber
= datenum(Y,M,D,H,MN,S
)H
, MN
,
and S
(hour, minute, and second) arrays. The arrays
must be of the same size (or any can be a scalar). You also can specify
the input arguments as a date vector, [Y,M,D,H,MN,S]
.
To create arbitrarily shaped output, use the datenum(Y,M,D)
and datenum(Y,M,D,H,MN,S)
syntaxes.
The datenum(DateVector)
syntax creates only a column
vector of date numbers.
datenum(2013,[1 3; 2 4],ones(2,2))
ans = 735235 735294 735266 735325