This makes it easy to determine, for example, the 3rd Wednesday of the month. Except I need to be able to determine the last occurrence of a day of the month (let's say the last Friday). As some months have 4 weeks and others have 5, well..that's my problem.
Posted: Sun Oct 04, 2020 7:38 pm Post subject: Re: Last occurrence of a day of the month
KenHorse wrote:
I've been using the following to determine the nth occurrence of a day of ethe month and it works well:
The shown function does nothing more than retrieving the n-th week in a month for a certain numbered day, it does not retrieve the name of said day.
Quote:
This makes it easy to determine, for example, the 3rd Wednesday of the month
'This' for sure not. Possible however in combination with other, not shown functions.
Quote:
Except I need to be able to determine the last occurrence of a day of the month (let's say the last Friday). As some months have 4 weeks and others have 5, well..that's my problem.
Calculate the date of the 5th occurence, then check if the result's month is the same as the month in request.
If not, the 4th occurence is valid.
I do remember this issue some while ago here in the forum.
Afair there were two competing solutions, my solution was to use Bascom's convert functions.
You may look that up, it provides the desired solution.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum