how to create regular interval date with time stamp?

35 views (last 30 days)
I want to create a 15min time stamp with from date 14th Aug 2019 time 0:00 AM to 8th june 2020 time 23:45 PM and format should be like this
8/14/2019 12:00:00 AM
8/14/2019 12:15:00 AM
8/14/2019 01:00:00 AM
...........
...........
..........
..........
t/ill
6/8/2020 23:45:00 PM

Accepted Answer

Star Strider
Star Strider on 31 Jul 2020
Try this:
Timestamp = datetime([2019 08 14 0 0 0]) : minutes(15) : datetime([2020 06 08 23 45 00]);
Timestamp.Format = 'M/d/yyyy H:mm:ss a'; % Set Format
Timestamp = Timestamp.'; % Transpose To Column
Sample = [Timestamp(1:5); Timestamp(end-4:end)] % View Result (Delete)
producing:
Sample =
10×1 datetime array
8/14/2019 00:00:00 AM
8/14/2019 00:15:00 AM
8/14/2019 00:30:00 AM
8/14/2019 00:45:00 AM
8/14/2019 01:00:00 AM
6/8/2020 22:45:00 PM
6/8/2020 23:00:00 PM
6/8/2020 23:15:00 PM
6/8/2020 23:30:00 PM
6/8/2020 23:45:00 PM
The formats you want are not compatible.
You can have this format:
Timestamp.Format = 'M/d/yyyy H:mm:ss a'; % Set Format
or this format:
Timestamp.Format = 'M/d/yyyy h:mm:ss a'; % Set Format
(note the ‘H’ or ‘h’ differences), but not both.
.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!