Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default WEEKNUM() Question

The results of WEEKNUM() don't correspond with the calendaring system I
want.

My first question is simple: How does the WEEKNUM() algorithm work? If I
can figure out what it's based on, I can probably match it to the calendar
I'm using. It looks like it's anywhere from 1 day off to 2 days off from my
calendar, depending on when my week decides to start.

The calendar I have starts on Mondays and assigns WEEK-1 to the first week
of January with at least 4 days in it. So if WEEKDAY(DATE(YEAR,1,1),2) is 5
(Friday) or greater, then the week doesn't start until WEEKDAY() yields 1.
This means that up to first 4 days of January would be considered WK 52 (or
53).

I started to wonder if there was a better way to do it, when my formula
started approaching 150 characters, and I still hadn't accounted for the WK
53 case or leap year. I've never built my own function, but something tells
me it would be the cleanest way to do it.

I have a pdf of about 15 years worth, if anyone is interested in taking a
look. Since it's .5MB, I won't try to attach it.
<http://www.capeyork.us/data/Calendar.pdf.

Thanks in advance to the first "smart-guy" to help me out. I've been hoping
to make time to figure this out for quite a while now.

  #2   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,440
Default WEEKNUM() Question

Read this:

http://www.cpearson.com/excel/weeknum.htm

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Jared Call" wrote in message ...
| The results of WEEKNUM() don't correspond with the calendaring system I
| want.
|
| My first question is simple: How does the WEEKNUM() algorithm work? If I
| can figure out what it's based on, I can probably match it to the calendar
| I'm using. It looks like it's anywhere from 1 day off to 2 days off from my
| calendar, depending on when my week decides to start.
|
| The calendar I have starts on Mondays and assigns WEEK-1 to the first week
| of January with at least 4 days in it. So if WEEKDAY(DATE(YEAR,1,1),2) is 5
| (Friday) or greater, then the week doesn't start until WEEKDAY() yields 1.
| This means that up to first 4 days of January would be considered WK 52 (or
| 53).
|
| I started to wonder if there was a better way to do it, when my formula
| started approaching 150 characters, and I still hadn't accounted for the WK
| 53 case or leap year. I've never built my own function, but something tells
| me it would be the cleanest way to do it.
|
| I have a pdf of about 15 years worth, if anyone is interested in taking a
| look. Since it's .5MB, I won't try to attach it.
| <http://www.capeyork.us/data/Calendar.pdf.
|
| Thanks in advance to the first "smart-guy" to help me out. I've been hoping
| to make time to figure this out for quite a while now.
|


  #3   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default WEEKNUM() Question

I think you are referring to ISO week numbers.

Try this formula for calculating that week number

=INT((A1-DATE(YEAR(A1-WEEKDAY(A1-1)+4),1,3)+WEEKDAY(DATE(YEAR(A1-WEEKDAY(A1-
1)+4),1,3))+5)/7)

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jared Call" wrote in message
...
The results of WEEKNUM() don't correspond with the calendaring system I
want.

My first question is simple: How does the WEEKNUM() algorithm work? If I
can figure out what it's based on, I can probably match it to the calendar
I'm using. It looks like it's anywhere from 1 day off to 2 days off from

my
calendar, depending on when my week decides to start.

The calendar I have starts on Mondays and assigns WEEK-1 to the first week
of January with at least 4 days in it. So if WEEKDAY(DATE(YEAR,1,1),2) is

5
(Friday) or greater, then the week doesn't start until WEEKDAY() yields 1.
This means that up to first 4 days of January would be considered WK 52

(or
53).

I started to wonder if there was a better way to do it, when my formula
started approaching 150 characters, and I still hadn't accounted for the

WK
53 case or leap year. I've never built my own function, but something

tells
me it would be the cleanest way to do it.

I have a pdf of about 15 years worth, if anyone is interested in taking a
look. Since it's .5MB, I won't try to attach it.
<http://www.capeyork.us/data/Calendar.pdf.

Thanks in advance to the first "smart-guy" to help me out. I've been

hoping
to make time to figure this out for quite a while now.



  #4   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,123
Default WEEKNUM() Question

See also
http://www.rondebruin.nl/weeknumber.htm

and
http://www.rondebruin.nl/isodate.htm


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Jared Call" wrote in message ...
The results of WEEKNUM() don't correspond with the calendaring system I
want.

My first question is simple: How does the WEEKNUM() algorithm work? If I
can figure out what it's based on, I can probably match it to the calendar
I'm using. It looks like it's anywhere from 1 day off to 2 days off from my
calendar, depending on when my week decides to start.

The calendar I have starts on Mondays and assigns WEEK-1 to the first week
of January with at least 4 days in it. So if WEEKDAY(DATE(YEAR,1,1),2) is 5
(Friday) or greater, then the week doesn't start until WEEKDAY() yields 1.
This means that up to first 4 days of January would be considered WK 52 (or
53).

I started to wonder if there was a better way to do it, when my formula
started approaching 150 characters, and I still hadn't accounted for the WK
53 case or leap year. I've never built my own function, but something tells
me it would be the cleanest way to do it.

I have a pdf of about 15 years worth, if anyone is interested in taking a
look. Since it's .5MB, I won't try to attach it.
<http://www.capeyork.us/data/Calendar.pdf.

Thanks in advance to the first "smart-guy" to help me out. I've been hoping
to make time to figure this out for quite a while now.



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
Possibly a loaded question, but I think mileslit Excel Discussion (Misc queries) 1 September 10th 05 01:18 AM
How do I find and replace a question mark in Excel? Ranpalandil Excel Discussion (Misc queries) 1 September 7th 05 10:20 PM
Newbie With A Question Michael Excel Worksheet Functions 0 July 28th 05 11:50 PM
Anybody Help with previous question Anthony Excel Discussion (Misc queries) 1 July 26th 05 01:26 PM
Hints And Tips For New Posters In The Excel Newsgroups Gary Brown Excel Worksheet Functions 0 April 15th 05 05:47 PM


All times are GMT +1. The time now is 12: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"