Who likes working with calendars?
I don't but I really need to figure this either with a function or calculation.
Using the functions below I can work out how many Mondays, Tuesdays etc in any given month but I am stuck on how to
calculate how many Mondays, Tuesday etc remaining from any given date in a given month.
e.g.
Start = Sept 16th 2003
(lastdow(start,2)-firstdow(start,2)+7)/7 ' using functions below gives me 5 Mondays in September 2003
But now I need Mondays remaining from 'start'
Mondays remaining = 2 ' if start 16th Sept
Mondays remaining = 3 'if start 15th Sept
Mondays remaining = 4 'if start= 2nd Sept
How many Mondays remain from any given start date in any given month
Here are some useful function that I frequently use
function Firstdow as D(dateval as D,day_num as n)
' return the first date of a given day for any given month
temp=Dateval-DAY(dateval)+1
Firstdow=temp+7-mod(dow(temp+6-day_num),7)-1
end function
function Lastdow as D(dateval as D,day_num as n)
' return the last date of a given day for any given month
temp=Addmonths(Dateval-DAY(dateval)+1,1)
Lastdow=temp-mod(dow(temp+6-day_num),7)-1
end function
function LastFrid as D(dateval as D)
' returns the last Friday of any given month
temp=Addmonths(Dateval-DAY(dateval)+1,1)
LastFrid=temp-mod(dow(temp),7)-1
end function
Michael
I don't but I really need to figure this either with a function or calculation.
Using the functions below I can work out how many Mondays, Tuesdays etc in any given month but I am stuck on how to
calculate how many Mondays, Tuesday etc remaining from any given date in a given month.
e.g.
Start = Sept 16th 2003
(lastdow(start,2)-firstdow(start,2)+7)/7 ' using functions below gives me 5 Mondays in September 2003
But now I need Mondays remaining from 'start'
Mondays remaining = 2 ' if start 16th Sept
Mondays remaining = 3 'if start 15th Sept
Mondays remaining = 4 'if start= 2nd Sept
How many Mondays remain from any given start date in any given month
Here are some useful function that I frequently use
function Firstdow as D(dateval as D,day_num as n)
' return the first date of a given day for any given month
temp=Dateval-DAY(dateval)+1
Firstdow=temp+7-mod(dow(temp+6-day_num),7)-1
end function
function Lastdow as D(dateval as D,day_num as n)
' return the last date of a given day for any given month
temp=Addmonths(Dateval-DAY(dateval)+1,1)
Lastdow=temp-mod(dow(temp+6-day_num),7)-1
end function
function LastFrid as D(dateval as D)
' returns the last Friday of any given month
temp=Addmonths(Dateval-DAY(dateval)+1,1)
LastFrid=temp-mod(dow(temp),7)-1
end function
Michael
Comment