S
SPR
Evening,
I have created the following formula to look up monthly
dates from a common start date, subject to the following
rules
No Weekends
No Holidays
If the date falls on a weekend or holiday, roll back the
date if the next valid date in the list belongs to the
next month, or roll forward the date if the next valid
date belongs to the same month.
This is date convention in some financial markets
To get rid of all weekends i used
=workday(date,1,holidaylist)
To get a sequential list of valid days.
Variables:
datelist=sequential datelist detailed above
start=common startdate (usually next workday)
mnth=numbers of months to be added
Index and match functions, combined with edate, are then
run through a series of if functions, to check if the
edate date exists on the datelist, or needs to be rolled
forward or back
=IF(MONTH(INDEX(datelist,MATCH(INDEX(datelist,MATCH(EDATE
(start,mnth),datelist,1)),datelist)+1))>MONTH(INDEX
(datelist,MATCH(EDATE(start,mnth),datelist,1))),INDEX
(datelist,MATCH(EDATE(start,mnth),datelist,1)),IF(((INDEX
(datelist,MATCH(INDEX(datelist,MATCH(EDATE
(start,mnth),datelist,1)),datelist)+1))-INDEX
(datelist,MATCH(EDATE(start,mnth),datelist,1)))>1,INDEX
(datelist,MATCH(INDEX(datelist,MATCH(EDATE
(start,mnth),datelist,1)),datelist)+1),INDEX(datelist,MATCH
(EDATE(start,mnth),datelist,1))))
As you can see, this quite a messy formula, can any of you
bright sparkes think of shorter way to do it?
Alternatively, is there any handy little software/web
pages that help people debug a formula like this? Will be
a tad tricky for someone not familiar with the formula to
debug it if something goes wrong.
FYI, if 30 Sep is the "start", I get the following months
dates
1 30-Oct-03
2 28-Nov-03
3 30-Dec-03
4 30-Jan-04
5 27-Feb-04
6 30-Mar-04
7 30-Apr-04
8 31-May-04
9 30-Jun-04
10 30-Jul-04
11 30-Aug-04
12 30-Sep-04
Many thanks in advance
Cheers !
I have created the following formula to look up monthly
dates from a common start date, subject to the following
rules
No Weekends
No Holidays
If the date falls on a weekend or holiday, roll back the
date if the next valid date in the list belongs to the
next month, or roll forward the date if the next valid
date belongs to the same month.
This is date convention in some financial markets
To get rid of all weekends i used
=workday(date,1,holidaylist)
To get a sequential list of valid days.
Variables:
datelist=sequential datelist detailed above
start=common startdate (usually next workday)
mnth=numbers of months to be added
Index and match functions, combined with edate, are then
run through a series of if functions, to check if the
edate date exists on the datelist, or needs to be rolled
forward or back
=IF(MONTH(INDEX(datelist,MATCH(INDEX(datelist,MATCH(EDATE
(start,mnth),datelist,1)),datelist)+1))>MONTH(INDEX
(datelist,MATCH(EDATE(start,mnth),datelist,1))),INDEX
(datelist,MATCH(EDATE(start,mnth),datelist,1)),IF(((INDEX
(datelist,MATCH(INDEX(datelist,MATCH(EDATE
(start,mnth),datelist,1)),datelist)+1))-INDEX
(datelist,MATCH(EDATE(start,mnth),datelist,1)))>1,INDEX
(datelist,MATCH(INDEX(datelist,MATCH(EDATE
(start,mnth),datelist,1)),datelist)+1),INDEX(datelist,MATCH
(EDATE(start,mnth),datelist,1))))
As you can see, this quite a messy formula, can any of you
bright sparkes think of shorter way to do it?
Alternatively, is there any handy little software/web
pages that help people debug a formula like this? Will be
a tad tricky for someone not familiar with the formula to
debug it if something goes wrong.
FYI, if 30 Sep is the "start", I get the following months
dates
1 30-Oct-03
2 28-Nov-03
3 30-Dec-03
4 30-Jan-04
5 27-Feb-04
6 30-Mar-04
7 30-Apr-04
8 31-May-04
9 30-Jun-04
10 30-Jul-04
11 30-Aug-04
12 30-Sep-04
Many thanks in advance
Cheers !