Rule for shifting datetime
values, specified as
'next'
, 'previous'
,
'nearest'
, 'current'
, a scalar
integer, or an array of integers.
The table describes the rules for shifting datetime
values.
Rule | Description |
---|
'next'
| Shift datetime value to next
unit of time or specified day of
week. Note: This rule is the default rule for
the 'dayofweek' input
argument. |
'previous'
| Shift datetime value to previous
unit of time or specified day of week. |
'nearest'
| Shift datetime value to nearest
occurrence of the unit of time or specified day of
week. In effect, this rule rounds
datetime values. |
'current'
| Shift datetime value within the
current unit of time, or to the specified day within the
current week. Note: This rule is the default rule for
the 'start' and
'end' input
arguments. |
1
| Equivalent to the 'next'
rule. |
n , where n >
1
| Equivalent to the 'next' rule
applied n times. |
0
| Equivalent to the 'current'
rule. |
-1
| Equivalent to the 'previous'
rule. |
-n , where n >
1
| Equivalent to the 'previous'
rule applied n times. |
Array of integers | Shifts each value in t according
to the rule specified by the corresponding integer in
rule . The input
arguments t and
rule must have the same size, or
one of them must be scalar. |
Behavior When datetime
Values
Match 'dayofweek'
Argument
If you specify 'dayofweek'
and t
contains datetime
values that fall on the specified 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','Thursday',rule
)
returns a datetime
value with a date of December 24, 2015
if rule
is
'next'
, 'previous'
,
'nearest'
, 1
, or
-1
, because December 24, 2015 is a Thursday.