ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Number of sundays (https://www.excelbanter.com/excel-programming/323810-number-sundays.html)

Mark Scholes

Number of sundays
 
Hi,
I have a date which is a sunday and I need to find how
many sundays it is from the begining of the year.

Thanks MarkS

Robin Hammond[_2_]

Number of sundays
 
Mark,

Try this.

Function SundaysFromStartOfYear(dtInput As Date)
'assumes dtinput is a sunday
SundaysFromStartOfYear = Int((dtInput - DateSerial(Year(dtInput), 1, 1)) /
7) + 1
End Function

Robin Hammond
www.enhanceddatasystems.com

"Mark Scholes" wrote in message
...
Hi,
I have a date which is a sunday and I need to find how
many sundays it is from the begining of the year.

Thanks MarkS




Ron Rosenfeld

Number of sundays
 
On Tue, 22 Feb 2005 16:36:43 -0800, "Mark Scholes"
wrote:

Hi,
I have a date which is a sunday and I need to find how
many sundays it is from the begining of the year.

Thanks MarkS


With your Sunday date in A1:

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

gives the Sunday number; counting the first Sunday in the year as number 1.

If you don't want to count the first Sunday, then omit the +1 at the end of the
formula.


--ron

Ron Rosenfeld

Number of sundays
 
On Tue, 22 Feb 2005 16:36:43 -0800, "Mark Scholes"
wrote:

Hi,
I have a date which is a sunday and I need to find how
many sundays it is from the begining of the year.

Thanks MarkS


OOPS.

My formula should be:

=DATE(YEAR(A1),1,8)-WEEKDAY(DATE(YEAR(A1),1,7))


--ron

Ron Rosenfeld

Number of sundays
 
On Tue, 22 Feb 2005 16:36:43 -0800, "Mark Scholes"
wrote:

Hi,
I have a date which is a sunday and I need to find how
many sundays it is from the begining of the year.

Thanks MarkS


Maybe now that I am awake I can get it correct:

=(A1-DATE(YEAR(A1),1,8)+WEEKDAY(DATE(YEAR(A1),1,7)))/7+1

--ron


All times are GMT +1. The time now is 05:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com