# Calculating calendar week numbers

I'm developing a time-sheet form for work.

However, after looking at diaries from several years (and the Web), I can't actually determine how the week number is actually derived.

I thought that Week 1 would be the week in which Jan 1st fell - but no!!

Some years also have 53 weeks!!!

Oh Father Time, reveal thy secrets.
LVL 4
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Commented:
Trivia:
Every year divisable by 4 is a leap year;  EXCEPT those years
divided by 400 are not.  In otherwords ladies and gentlemen,
the year 2000 is NOT a leap year.
Commented:
there is an algorithm for that. I remember i've got it in a ti59 or ti58 manual.
Commented:
What is a ti59 or ti58 manual?
Commented:
Week number is not a universally defined concept. You could invent your own system if you liked but I guess you are trying to mimic the system already in place at work.

You might find that week 1 is the week in which the first Sunday (or Monday) of the year occurs. This would mean that any days prior to this would fall in week 0. You might also find that some other date is used as a datum, such as the end of the tax year or Christmas Day.
Author Commented:
I agree with Martike, Ozo had the answer in the first place as regards time. You should submit yours as the answer, Ozo!!

Martike, your comment regarding the year was correct (I already actually knew this one) unlike Surgeman's. Thank you for all your comments though.

As to where I was, I was monitoring the comments/answers from my work's logon to experts-exchange. I got what I wanted from Ozo's comment and was waiting (and hoping) that he submitted as the answer.

As a result, I'll give hime another day to claim his prize. If he doesn't, then you can have it, Martike, if you submit it as the answer, that is.
Commented:
martike is right about leap years.

But the usual argument for neglecting 1999-12-31 24:00:00, that "there was no year 0"
seems rather silly to me.   There was no year 1 either.
It was not until many years later that the year 1 was retroactively designated.
1-1-1 00:00:00 was not celebrated as the dawn of a millenium,
at the time, it wasn't even considered the start of a new year.
Author Commented:
And they would have sorted out the Millenium Bug one thousand years ago!!
Commented:
Bah!-)
Zero exists in our numbering system now, and a year 0 can be designated as easily as 1 or 2525 or -99
(I won't quibble about whether 0-99 should be the 1st century or the 0th :-)

I didn't see Noggy's comment before my last post, so here is a summary of the answer:

Week 1 is the week containing 4 January, the first week with a majority of it's days in the new year.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Well done & congratulations (for a measly 10 credits!!).

I still don't know why you didn't post it as an answer in the first place, it was just what I wanted. Maybe I didn't word it correctly (or you didn't care for the points!).

I would like to take this opportunity to thank you all for your comments\answers\discussion - I think this question is quite well flogged for this year!!

Thanks again.

Nog :->
Commented:
You're welcome.

Your question seemed to be worded clearly enough, but I've been mistaken before when I thought
I understood what a question was asking, so I didn't know that it was just what you wanted
until I saw your comment.
(and, yes, the risk of missing out on the points didn't seem too intolerably tragic:-)
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Hardware

From novice to tech pro — start learning today.