days - Duration in days - MATLAB (original) (raw)

Main Content

Syntax

Description

D = days([X](#bugc82y-1-X)) returns an array of fixed-length days equivalent to the values in the input array.

The days function converts betweenduration and double values. To display a duration in units of days, set its Format property to'd'.

example

Examples

collapse all

X = magic(2); D = days(X)

D = 2×2 duration 1 day 3 days 4 days 2 days

Add each number of fixed-length days to the current date and time.

t = 2×2 datetime 02-Feb-2025 08:52:21 04-Feb-2025 08:52:21 05-Feb-2025 08:52:21 03-Feb-2025 08:52:21

Create a duration array.

X = hours(23:20:95) + minutes(45)

X = 1×4 duration 23.75 hr 43.75 hr 63.75 hr 83.75 hr

Convert each duration in X to a number of days.

D = 1×4

0.9896    1.8229    2.6562    3.4896

Input Arguments

collapse all

Input array, specified as a numeric array, duration array, or logical array.

Tips

Extended Capabilities

expand all

Thedays function fully supports tall arrays. For more information, see Tall Arrays.

Version History

Introduced in R2014b