我们可以fbusdate用来获得一个月的第一个工作日:
Date = fbusdate(Year, Month);
Run Code Online (Sandbox Code Playgroud)
但是,我们如何获得一周的第一个工作日?
例如,在我发布这一周的那一周,2017年7月9日星期一在美国度假:
isbusday(736942) % = 0
Run Code Online (Sandbox Code Playgroud)
我如何确定本周的第一个工作日是第二天736943?
解决了。这是一个基于@m7913d的答案的函数:
function Busday = fbusdateweek(date)
% Return the first business day after Sunday
% 'date' is a datenum input
dperiod = date-6:date;
sundays = weekday(dperiod)==1;
sunday = find(sundays==1,1,'first');
datesunday = dperiod(sunday);
% -->
Busday = busdate(datesunday);
end
Run Code Online (Sandbox Code Playgroud)