DETERMINATION OF THE CALENDAR WEEK DATE

GIVEN THE CALENDAR ORDINAL DATE

Aristeo Canlas Fernando

To determine the calendar week date (YYYY-Www-D or YYYYWwwD) given the calendar ordinal date (YYYY-DDD or YYYYDDD), determine first if year is a common year or a leap year.  A leap year is a year that is divisible by 4 except century year which should be divisible by 400.

Common Year

If  the ordinal date is 365, proceed directly to step 4.  The week number (ww) is 52 and the week day number (D) is 8.  This is for December 31.

1.  Divide ordinal date (DDD) by 7 to get quotient consisting of whole number and remainder.
2. Add 1 to the whole number to get the week number (ww).
3. The remainder is the week day number (D).
4. Append the week number (ww) and week day number (D) to year (YYYY) to get the calendar week date (YYYYWwwD).

Leap Year

If the ordinal date is 366, proceed directly to step 4.  The week number (ww) is 52 and the week day number (D) is 8.  This is for December 31.

If the ordinal date is 183, proceed directly to step 4.  The week number (ww) is 26 and the week day number (D) is 8.  This is for June 31.

1. Divide the ordinal date (DDD) by 7 to get quotient consisting of whole number and remainder.
2. Add 1 to the whole number to get the week number (ww).
3. If week number (ww) is more than 26, add 1 to the remainder to get the week day number (D).
4. Append the week number (ww) and week day number (D) to year (YYYY) to get the calendar week date (YYYYwwD).

File:  findweekdate.htm                 Date first uploaded:  2007 September 3      Rev. 0