Get next business day without taking into account holidays and saturdays
4 views (last 30 days)
Dear MATLAB experts,
I'm trying to get the next business day of each date in an array without taking into account saturdays, but I can't manage to do so with the function 'busdate' from MATLAB. The aim is to get the next so named "weekday" discarding holidays for each one of the dates in the array. I would really appreciate your help, thank you in advance.
the cyclist on 17 Oct 2021
The issue is not a problem with busdate(), but with your understanding of the input. 20170610 is being interpreted as a serial date number. (See this documentation.)
datestr(20170610) % Serial date number 20170610 is April 2, 5225 which is a Wednesday
Here is your intended result, by first converting from the serial date number to a datetime.
busdate(datetime(num2str(20170610),'InputFormat','yyyyMMdd')) % Converted the serial date number to a datetime
Using the canonical datetime format for all dates in MATLAB is highly encouraged.