03-Nov-2013 14:00:00
04-Nov-2013 08:00:00
05-Nov-2013 02:00:00
Use the years, days, minutes, and seconds functions to create datetime and duration sequences
using other fixed-length date and time units. Create a sequence of duration values between 0 and 3
minutes, incremented by 30 seconds.
d = 0:seconds(30):minutes(3)
d = 1x7 duration
0 sec
30 sec
60 sec
90 sec
120 sec
150 sec
180 sec
Compare Fixed-Length Duration and Calendar Duration Step Sizes
Assign a time zone to t1 and t2. In the America/New_York time zone, t1 now occurs just before a
daylight saving time change.
t1.TimeZone = 'America/New_York';
t2.TimeZone = 'America/New_York';
If you create the sequence using a step size of one calendar day, then the difference between
successive datetime values is not always 24 hours.
t = t1:t2;
dt = diff(t)
dt = 1x4 duration
24:00:00
25:00:00
24:00:00
24:00:00
Create a sequence of datetime values spaced one fixed-length day apart,
t = t1:days(1):t2
t = 1x5 datetime
Columns 1 through 3
01-Nov-2013 08:00:00
02-Nov-2013 08:00:00
03-Nov-2013 07:00:00
Columns 4 through 5
04-Nov-2013 07:00:00
05-Nov-2013 07:00:00
Verify that the difference between successive datetime values is 24 hours.
dt = diff(t)
dt = 1x4 duration
24:00:00
24:00:00
24:00:00
24:00:00
Integer Step Size
If you specify a step size in terms of an integer, it is interpreted as a number of 24-hour days.
t = t1:1:t2
Generate Sequence of Dates and Time
7-15
Précédent

- 269/1450

Suivant