IRIS Toolbox Reference Manual

datrange

Numerically safe way to create a date range

Syntax

Rng = datrange(Start,End)
Rng = datrange(Start,End,Step)

Input arguments

Output arguments

Description

Most of the time, using a colon operator to create a date range works fine,

Start : Step : End

Under some (rather rare) circumstances, the colon operator may give incorrect results caused by rounding error difficulties since IRIS serial date numbers are non-integer values. In that case, the function datrange provides a safe workaround:

datrange(Start,End,Step)

is equivalent (but numerically safer) to

Start : Step : End

Example

The date ranges created in this example are identical, and no numerical inaccuracies exist:

r1 = qq(2000,1) : qq(2010,4);
r2 = datrange(qq(2000,1),qq(2010,4));
format long
r1 - r2