dateshift
Shift date or generate sequence of dates and times
Syntax
Description
t2 = dateshift(
shifts the dates and times in the input t
,'start',unit
)datetime
array. The
function shifts each element of the array back to the beginning of the unit of
time specified by unit
. The output t2
is
the same size as the input t
.
For example, if you shift 9:14 a.m., June 27, 2021 to the start of the hour, then the shifted value is 9:00 a.m., June 27, 2021. If you shift it to the start of the month, then the shifted value is 12:00 a.m., June 1, 2021.
t2 = dateshift(
shifts the dates and times ahead to the end of the unit of time specified by
t
,'end',unit
)unit
.
The end of a day, hour, minute, or second is also the beginning of the next day, hour, minute, or second. For example, if you shift 9:14 a.m., June 27, 2021 to the end of the hour, then the shifted value is 10:00 a.m., June 27, 2021.
The end of a year, quarter, month, or week is midnight at the beginning of the last day of that year, quarter, month, or week. For example, if you shift 9:14 a.m., June 27, 2021 to the end of the month, then the shifted value is 12:00 a.m., June 30, 2021.
t2 = dateshift(
shifts to the weekend day (either Saturday or Sunday) that occurs on or after
each t
,'dayofweek','weekend')datetime
value in array t
.
Examples
Input Arguments
Extended Capabilities
Version History
Introduced in R2014b