Main Content

days

Duration in days

Syntax

Description

example

D = days(X)returns an array of days equivalent to the values inX.

  • IfXis a numeric array, thenDis adurationarray in units of fixed-length days. A fixed-length day is equal to 24 hours.

  • IfXis adurationarray, thenDis adoublearray with each element equal to the number of fixed-length (24-hour) days in the corresponding element ofX.

Thedaysfunction converts betweendurationanddoublevalues. To display a duration in units of days, set itsFormatproperty to'd'.

Examples

collapse all

X = magic(2); D = days(X)
D =2x2 duration1 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 datetime25-Aug-2020 20:00:47 27-Aug-2020 20:00:47 28-Aug-2020 20:00:47 26-Aug-2020 20:00:47

Create adurationarray.

X = hours(23:20:95) + minutes(45)
X =1x4 duration23.75 hr 43.75 hr 63.75 hr 83.75 hr

Convert each duration inXto a number of days.

D = days(X)
D =1×40.9896 1.8229 2.6562 3.4896

Input Arguments

collapse all

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

Tips

  • dayscreates fixed-length (24 hour) days. To create days that account for Daylight Saving Time shifts when used in calendar calculations, use thecaldaysfunction.

Extended Capabilities

See Also

|

Introduced in R2014b