Get next business day without taking into account holidays and saturdays
1 次查看(过去 30 天)
显示 更早的评论
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.
4 个评论
the cyclist
2021-10-17
According to the documentation, Saturday and Sunday are not business days by default. (This can be changed by using the Weekend input.)
Can you give a small example of your input data and code, including a date that is giving a result you don't want?
采纳的回答
the cyclist
2021-10-17
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
busdate(20170610, 1)
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.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calendar 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!