Other Units of Dates and Time
You can specify other units of time such as week, day, and hour.
t1 = datetime('now')
t1 = datetime
01-Sep-2021 13:42:35
t = dateshift(t1,'start','hour',0:4)
t = 1x5 datetime
Columns 1 through 3
01-Sep-2021 13:00:00
01-Sep-2021 14:00:00
01-Sep-2021 15:00:00
Columns 4 through 5
01-Sep-2021 16:00:00
01-Sep-2021 17:00:00
Previous Occurrences of Dates and Time
Generate a sequence of datetime values beginning with the previous hour. Negative integers in the
last input to dateshift correspond to datetime values earlier than t1.
t = dateshift(t1,'start','hour',-1:1)
t = 1x3 datetime
01-Sep-2021 12:00:00
01-Sep-2021 13:00:00
01-Sep-2021 14:00:00
See Also
dateshift | linspace
Generate Sequence of Dates and Time
7-19
Précédent

- 273/1450

Suivant