My problem is the following:
I have a start day. For example: 30 - Oct - 2010
And I know how many business days I need to count back. For example: 250 business days.
Now I want to be able to calculate the start date.
Start date = (30 - Oct - 2010) - (250 Business Days) - (Amount of weekends during those 250 days).
But I don't know how to calculate the "amount of weekends".
Could anyone help me?
Thanks in advance.
Jonathan
You can do it this way in Matlab:
Comments:
0instart_weekdayindicates thatstart_dayis Mon;1indicates that it is Thu etc. The+4is needed because the reference date of thedatenumfunction is 01-Jan-0000.<5in the second line gives1for business days and0for weekends. The functioncumsumgives the cumulative sum from yesterday backwards, reaching untilmax(2*count_back,3)days into the past. The numbermax(2*count_back,3)is always enough (it could be adjusted more finely).1in the third line is needed because we want the first day into the past that gives the desiredcount_back. If that day is Mon, the previous Sun and Sat would also have the desiredcount_back, but we don't want them.