Duration in days
D = days( returns an array of days
equivalent to the values in
Xis a numeric array, then
durationarray in units of fixed-length days. A fixed-length day is equal to 24 hours.
doublearray with each element equal to the number of fixed-length (24-hour) days in the corresponding element of
days function converts between
double values. To display
a duration in units of days, set its
Format property to
Create Duration Array of Fixed-Length Days
X = magic(2); D = days(X)
D = 2x2 duration 1 day 3 days 4 days 2 days
Add each number of fixed-length days to the current date and time.
t = datetime('now') + D
t = 2x2 datetime 01-Sep-2022 03:28:29 03-Sep-2022 03:28:29 04-Sep-2022 03:28:29 02-Sep-2022 03:28:29
Convert Durations to Numeric Array of Days
X = hours(23:20:95) + minutes(45)
X = 1x4 duration 23.75 hr 43.75 hr 63.75 hr 83.75 hr
Convert each duration in
X to a number of days.
D = days(X)
D = 1×4 0.9896 1.8229 2.6562 3.4896
X — Input array
numeric array | duration array | logical array
Input array, specified as a numeric array, duration array, or logical array.
dayscreates fixed-length (24 hour) days. To create days that account for Daylight Saving Time shifts when used in calendar calculations, use the
Calculate with arrays that have more rows than fit in memory.
This function fully supports tall arrays. For more information, see Tall Arrays.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
This function fully supports code generation. For more information, see Code Generation for Duration Arrays (MATLAB Coder).
Run code in the background using MATLAB®
backgroundPool or accelerate code with Parallel Computing Toolbox™
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Introduced in R2014b