caldays

Calendar days, for date arithmetic that respects the calendar.

Category: Language Fundamentals > Data Types

Syntax

d = caldays(n)

Creates a calendarDuration of n calendar days.

Description

A calendar day moves the date forward by one civil day, keeping the clock time, even across a daylight-saving change where a day is not 24 hours long. For that reason it differs from days, which is a fixed 24-hour duration.

Add the result to a datetime: t + caldays(3). Several calendar units can be added together, as in calmonths(1) + caldays(2).

Input arguments

n
Numeric array of day counts (integers for exact calendar behavior).

Output arguments

d
calendarDuration array, same size as n.

Example

Adding days

t = datetime(2024,1,31);
t + caldays(1)
caldays(3)
Output
ans = datetime
   01-Feb-2024
ans = calendarDuration
   3d

See also

days calweeks calmonths calendarDuration datetime