Calendar duration in days
D = caldays( returns
an array representing calendar days equivalent to the values in array
X is a numeric array, then
calendarDuration array with each element equal
to the number of calendar days in the corresponding element of
Calendar days account for Daylight Saving Time shifts when used in
X is a
D is a
double array with
each element equal to the number of whole calendar days in the corresponding
X = magic(5); D = caldays(X)
D = 5x5 calendarDuration array 17d 24d 1d 8d 15d 23d 5d 7d 14d 16d 4d 6d 13d 20d 22d 10d 12d 19d 21d 3d 11d 18d 25d 2d 9d
Create an array of calendar durations. Then, convert each value to the equivalent number of whole calendar days.
X = caldays(8:10) + hours(1.2345)
X = 1x3 calendarDuration array 8d 1h 14m 4.2s 9d 1h 14m 4.2s 10d 1h 14m 4.2s
D = caldays(X)
D = 1×3 8 9 10
caldays returns a numeric array.
Add two calendar days to the current date and time.
t = datetime('now') + caldays(2)
t = datetime 03-Feb-2020 00:20:26
Create a sequence of consecutive dates beginning on March 18, 2014.
T = datetime([2014,03,18]) + caldays(0:4)
T = 1x5 datetime array 18-Mar-2014 19-Mar-2014 20-Mar-2014 21-Mar-2014 22-Mar-2014
Create a sequence of dates beginning on March 18, 2014, spaced 2 days apart.
T = datetime([2014,03,18]) + caldays(0:2:8)
T = 1x5 datetime array 18-Mar-2014 20-Mar-2014 22-Mar-2014 24-Mar-2014 26-Mar-2014
caldays creates days that account
for Daylight Saving Time shifts when used in calendar calculations.
To create exact fixed-length (24 hour) days, use the
This function fully supports tall arrays. For more information, see Tall Arrays.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).