If I have a date, how do I calculate the week number for that date within that year?
For example, in 2008, January 1st to January 6th are in week 1 and January 7th to the 13th are in week 2, so if my date was January 10th 2008, my week number would be 2.
An algorithm would be great to get me started and sample code would also help - I'm developing in C++ on Windows.
Just pass the current date as the parameter to this function. Then you will get the current week number. Hope it solves ur problem. Any suggestions are greatly welcome.
Sorry, i'm new here and cant comment on the answer itself but the pseudo code from the answer with the checkmark isnt compeltey correct.
you should not look for the "first of year's day", but for the last day of last year.
would be correct instead of
If you don't do this, the last weekday of last year (like Monday) would always be one week ahead.