G
Guest
Some time ago Klatuu helped me with a nice function that returns the last
Friday of any date entered. I've been working with it and it's great. Now I'm
trying to code some procedures to handle two exceptions and deal with a year
change problem.
Basically, I have a form with a text box where the user inputs (or selects
from a popup calendar, I haven't decided) a payment date, call it PayDate.
Using that I want to determine a couple of things. First, the last Friday of
the month for that date. With Klatuu's help that's the easy part. This is
used as the closing date for monthly fiscal transactions.
Now, we have two exceptions. If the month is either March or September, the
closing will actually be on the next to last Friday. Looking at what results
using the VBA immediate window, I'm playing with something like this for the
exceptions
?"09/"&(Format(LastFriday(#9/12/2006#),"dd")-7)&"/2006
which returns what I want, 9/22/2006
I can compose a procedure that will give me the correct closing dates for
the PayDate and the two exceptions, whether using if...then or case methods,
I'm not sure. I guess I'll try both and choose what is more elegant and brief.
Then, I want to output the actual start and end dates of each period to use
as a filter. I figure the start date as the prior month's closing date plus
one, and the ending date as the closing date. I have to figure that when the
PayDate is in January then the prior month's closing date has to subtract one
from the year as well as add one to the day.
I would appreciate any direction or suggestions on how to handle this.
Ray S.
Friday of any date entered. I've been working with it and it's great. Now I'm
trying to code some procedures to handle two exceptions and deal with a year
change problem.
Basically, I have a form with a text box where the user inputs (or selects
from a popup calendar, I haven't decided) a payment date, call it PayDate.
Using that I want to determine a couple of things. First, the last Friday of
the month for that date. With Klatuu's help that's the easy part. This is
used as the closing date for monthly fiscal transactions.
Now, we have two exceptions. If the month is either March or September, the
closing will actually be on the next to last Friday. Looking at what results
using the VBA immediate window, I'm playing with something like this for the
exceptions
?"09/"&(Format(LastFriday(#9/12/2006#),"dd")-7)&"/2006
which returns what I want, 9/22/2006
I can compose a procedure that will give me the correct closing dates for
the PayDate and the two exceptions, whether using if...then or case methods,
I'm not sure. I guess I'll try both and choose what is more elegant and brief.
Then, I want to output the actual start and end dates of each period to use
as a filter. I figure the start date as the prior month's closing date plus
one, and the ending date as the closing date. I have to figure that when the
PayDate is in January then the prior month's closing date has to subtract one
from the year as well as add one to the day.
I would appreciate any direction or suggestions on how to handle this.
Ray S.