Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Counting Fridays in a month

Hello group,

I have seen in clever past postings for "First Tuesday" and "Next
Monday" for the worksheeet.

Is there a one line worksheet formula that will deliver the number of
Fridays in a given month ?

One may assume certain givens eg. the day of the week of the 1st of
that month and/or the number of days in that month.

Thanks,

Michael Singmin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Counting Fridays in a month

Michael,

Assuming a date in A1,

=INT((DAY(DATE(YEAR(A1),MONTH(A1)+1,1)-WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,2))
) + 6 ) / 7 )

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Michael Singmin" wrote in message
...
Hello group,

I have seen in clever past postings for "First Tuesday" and "Next
Monday" for the worksheeet.

Is there a one line worksheet formula that will deliver the number of
Fridays in a given month ?

One may assume certain givens eg. the day of the week of the 1st of
that month and/or the number of days in that month.

Thanks,

Michael Singmin



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Counting Fridays in a month

On Sat, 19 Jun 2004 00:04:04 +0200, Michael Singmin wrote:

Hello group,

I have seen in clever past postings for "First Tuesday" and "Next
Monday" for the worksheeet.

Is there a one line worksheet formula that will deliver the number of
Fridays in a given month ?

One may assume certain givens eg. the day of the week of the 1st of
that month and/or the number of days in that month.

Thanks,

Michael Singmin


Here's another method, again with any date in the month in A1:

=4+(DAY(A1-DAY(A1)+CHOOSE(WEEKDAY(A1-DAY(A1)),5,4,3,2,1,7,6)+28)28)


--ron
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Counting Fridays in a month

Greetings Bob & Ron,

Bob, I am astounded by your fomula. Care to briefly explain the
thinking behind it. Also what if I want to count Mondays, what do I
change ?

Ron, I think there must be an error because your formula does not
even evaluate.

Many thanks,

Michael

================================================== =================
Michael Singmin wrote:

Hello group,

I have seen in clever past postings for "First Tuesday" and "Next
Monday" for the worksheeet.

Is there a one line worksheet formula that will deliver the number of
Fridays in a given month ?

One may assume certain givens eg. the day of the week of the 1st of
that month and/or the number of days in that month.

Thanks,

Michael Singmin


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Counting Fridays in a month

On Mon, 21 Jun 2004 19:48:26 +0200, Michael Singmin wrote:

Ron, I think there must be an error because your formula does not
even evaluate.


It works fine for me. Probably you are entering it incorrectly, or don't have
a true date in A1.

What do you see?

If you just see the formula, then you have entered it as text rather than as a
formula. Perhaps either you are entering a leading space, or you are entering
a <cr in the middle thrown in by your newsreader.


--ron


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Counting Fridays in a month

Michael,

It's quite straight-forward, when broken down. It's theory is to get the day
of the last Friday in the month, and by taking the integer value of that day
plus 6 divided by 7, you get the number of Fridays.

First we get the first of the next month DATE(YEAR(A1),MONTH(A1)+1,1)
Then we get the day of the week of the first of nexyt month
WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,2)) based upon a Saturday week stgarts
Subtract the latter from the former to get the last Friday
Then add 6, divide b y 7 and take teh integer value

For Mondays, just use

=INT((DAY(DATE(YEAR(A1),MONTH(A1)+1,1)-WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,6))
) + 6 ) / 7 )

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Michael Singmin" wrote in message
...
Greetings Bob & Ron,

Bob, I am astounded by your fomula. Care to briefly explain the
thinking behind it. Also what if I want to count Mondays, what do I
change ?

Ron, I think there must be an error because your formula does not
even evaluate.

Many thanks,

Michael

================================================== =================
Michael Singmin wrote:

Hello group,

I have seen in clever past postings for "First Tuesday" and "Next
Monday" for the worksheeet.

Is there a one line worksheet formula that will deliver the number of
Fridays in a given month ?

One may assume certain givens eg. the day of the week of the 1st of
that month and/or the number of days in that month.

Thanks,

Michael Singmin




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Counting Fridays in a month

Hi Michael!

Here's the collection based on Ron's formula:

With a date in A1:

Number of:
Mondays
=4+(DAY(A1-DAY(A1)+CHOOSE(WEEKDAY(A1-DAY(A1)),1,7,6,5,4,3,2)+28)28)
Tuesdays
=4+(DAY(A1-DAY(A1)+CHOOSE(WEEKDAY(A1-DAY(A1)),2,1,7,6,5,4,3)+28)28)
Wednesdays
=4+(DAY(A1-DAY(A1)+CHOOSE(WEEKDAY(A1-DAY(A1)),3,2,1,7,6,5,4)+28)28)
Thursdays
=4+(DAY(A1-DAY(A1)+CHOOSE(WEEKDAY(A1-DAY(A1)),4,3,2,1,7,6,5)+28)28)
Fridays
=4+(DAY(A1-DAY(A1)+CHOOSE(WEEKDAY(A1-DAY(A1)),5,4,3,2,1,7,6)+28)28)
Saturdays
=4+(DAY(A1-DAY(A1)+CHOOSE(WEEKDAY(A1-DAY(A1)),6,5,4,3,2,1,7)+28)28)
Sundays
=4+(DAY(A1-DAY(A1)+CHOOSE(WEEKDAY(A1-DAY(A1)),7,6,5,4,3,2,1)+28)28)

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Counting Fridays in a month

Sorry Ron,

It was the leading space that I did not notice.
I copied it directly from your posting.

Thanks,

Michael
================================================== ========

Ron Rosenfeld wrote:

On Mon, 21 Jun 2004 19:48:26 +0200, Michael Singmin wrote:

Ron, I think there must be an error because your formula does not
even evaluate.


It works fine for me. Probably you are entering it incorrectly, or don't have
a true date in A1.

What do you see?

If you just see the formula, then you have entered it as text rather than as a
formula. Perhaps either you are entering a leading space, or you are entering
a <cr in the middle thrown in by your newsreader.


--ron


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Counting Fridays in a month

"Bob Phillips" wrote...
Assuming a date in A1,

=INT((DAY(DATE(YEAR(A1),MONTH(A1)+1,1)
-WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,2)))+6)/7)

...

Too long. Try

=4+(MOD(WEEKDAY(A1-DAY(A1),3)-WDN,7)-DAY(A1-DAY(A1)+32)2)

where WDN is the weekday number for 0=Monday, ..., 6=Sunday.

--
To top-post is human, to bottom-post and snip is sublime.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
formula for last Fridays date Pete Excel Discussion (Misc queries) 6 February 20th 07 06:18 PM
show fridays Tanner Excel Worksheet Functions 2 March 27th 06 02:43 AM
Counting Rows by Month [email protected] New Users to Excel 6 November 28th 05 02:03 PM
Calculating the number of Fridays in a month Greg Ward Excel Worksheet Functions 5 March 2nd 05 05:47 PM
Make an Excel series of first and third fridays of each month? Elliot Excel Discussion (Misc queries) 1 January 15th 05 09:32 PM


All times are GMT +1. The time now is 02:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"