Rule for shifting datetime values, specified as a character vector, string scalar, scalar
integer, or an array of integer values. If rule
is a
character vector or string, it must be one of the following.
Value of rule | Description |
---|
'next' | Shift datetime to next unit of time or specified day.
(Default
rule for day of week.) |
'previous' | Shift datetime to previous unit of time or specified day. |
'nearest' | Shift datetime to nearest occurrence of unit of time or specified
day. |
'current' | Shift datetime within the current unit of time, or to the specified
day in the current week.
(Default rule for unit of
time.) |
If rule
is an integer or an array of integers,
then:
When used with the input argument, unit
, 0
corresponds
to the start or end of the current unit for each datetime, 1
corresponds
to the next unit, -1
corresponds to the previous
unit, and so on.
When used with the input argument, dow
, 0
corresponds
to the specified day in the current week for each datetime, 1
corresponds
to the next occurrence of the specified day, -1
corresponds
to the previous occurrence, and so on.
t
and rule
must
be the same size, or one must be a scalar.
If you specify 'dayofweek'
and t
contains
datetime values that fall on that day of the week, then dateshift
treats
those datetime values as the next or previous occurrences of the specified
day of the week. For example, dateshift(datetime(2015,12,24),'dayofweek','thu',rule)
returns
a datetime value with a date of December 24, 2015 if rule
is 'next'
, 'previous'
, 1
,
or -1
, because December 24, 2015 is a Thursday.