How to select a group of consecutive (yet excluding weekends and holidays) dates between a certain date A and a certain date B from datetime?

2 次查看(过去 30 天)
Hi, I have a column of datetime (business days from 2012 to 2019). From this datetime, I would like to select a group of dates between a certain date (dStart), and another certain date (dEnd).
For example, if dStart was 06-Nov-2012 and dEnd was 05-Dec-2012, I want to select all dates I have from the datetime, including dStart and dEnd.
I believe that there is a way to do this, but I don't know how to do it.
Could you please explain to me how to achieve this?
Thank you!!!

回答(1 个)

Guillaume
Guillaume 2019-7-31
If I understood correctly, use the isbetween function:
%bus_dates: a datetime vector of all business dates between 2012 and 2019
%dStart: start date
%dEnd: end date
selected_dates = bus_dates(isbetween(bus_dates, dStart, dEnd))

类别

Help CenterFile Exchange 中查找有关 Time Series Objects 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by