FUNCTION REFERENCE

between

Calendar duration separating two datetimes.

Calendar duration separating two datetimes.

Syntax

cd = between(t1,t2)

Returns whole years and months, followed by remaining calendar days and elapsed time. Scalar expansion is supported. Adding the result to t1 reconstructs t2.

Example

a = datetime(2023,1,31); b = datetime(2024,3,3); cd = between(a,b); a + cd

Differences from MATLAB: Unit-selection options are not supported. Both datetimes must use the same time zone.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.