MATLAB Answers

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?

1 view (last 30 days)
Juniper Sohn
Juniper Sohn on 31 Jul 2019
Answered: Guillaume on 31 Jul 2019
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!!!

  0 Comments

Sign in to comment.

Answers (1)

Guillaume
Guillaume on 31 Jul 2019
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))

  0 Comments

Sign in to comment.


Translated by