Lookup in a loop
Posted: Thu Apr 04, 2013 9:21 pm
Hi All,
I need to implement a logic where in i feel i would have to do a lookup in a loop. The requirement is something like this:
I have an input date and i check if the data is a weekend or a country holiday. I am checking the weekend by using WeekdayFromDate function and for checking country holiday i am doing a lookup on the holiday calendar table. If the date is a weekend or a holiday i offset it accordingly to get a normal business day. However once i am done with the offset i have to check again the weekend and holiday logic and for checking the holiday i need to do the lookup again. This process i need to repeat till it is a working day.
For example, let us assume the input date is 5th April 2013 and it is a country holiday so i offset it by 1 and end up with a weekend. So, i check it again for weekend and offset it by 2 to get to Monday 8th April 2013. Incidentally Monday is again a holiday and i need to offset the date again by 1 day and get the business day. Once offset done then check again for weekend and holiday. So basically i need to increment the date till i get a normal business day.
I hope the above example is helpful.
Can i request for some help in this regard. Like how do i lookup the holiday table in a loop and increment the date till i get a valid business day. Any help is highly appreciated.
Thank you,
Punar
I need to implement a logic where in i feel i would have to do a lookup in a loop. The requirement is something like this:
I have an input date and i check if the data is a weekend or a country holiday. I am checking the weekend by using WeekdayFromDate function and for checking country holiday i am doing a lookup on the holiday calendar table. If the date is a weekend or a holiday i offset it accordingly to get a normal business day. However once i am done with the offset i have to check again the weekend and holiday logic and for checking the holiday i need to do the lookup again. This process i need to repeat till it is a working day.
For example, let us assume the input date is 5th April 2013 and it is a country holiday so i offset it by 1 and end up with a weekend. So, i check it again for weekend and offset it by 2 to get to Monday 8th April 2013. Incidentally Monday is again a holiday and i need to offset the date again by 1 day and get the business day. Once offset done then check again for weekend and holiday. So basically i need to increment the date till i get a normal business day.
I hope the above example is helpful.
Can i request for some help in this regard. Like how do i lookup the holiday table in a loop and increment the date till i get a valid business day. Any help is highly appreciated.
Thank you,
Punar