## 7.1 Day of the Week Algorithms

In this section, the convention is used that the numbers from 0 through 6 correspond to the day of the week names as follows:
 0 Sunday 1 Monday 2 Tuesday 3 Wednesday 4 Thursday 5 Friday 6 Saturday
Given the beginning of a day (0.00 hours) whose date is expressed as Julian Day Number JD (fractional part 0.5), the day of the week is equal to

(INT(JD + 1.5)) modulo 7

It is written in this form because some software implementations of the modulo function round up any fractional argument. Note also that some modulo implementations do not assure that the result is positive when the argument is negative. Microsoft's Visual Basic is an example of an implementation that suffers from both problems.

If the fractional part of the Julian Day number for a day beginning at 0 hours is truncated (removed or made zero) it represents noon of the previous day. If a date expressed as such a Julian Day number is used, then the day of the week is equal to: (INT(JD + 2)) modulo 7.

For example,

Friday, December 31, 1999 at noon is JD 2451544
Saturday, January 1, 2000 0 hours is JD 2451544.5
Saturday, January 1, 2000 at noon is JD 2451545

INT(2451544+2) = INT(2451544.5 + 1.5) = 2451546

and 2451546 mod 7 = (350220*7+6) mod 7 = 6 (Saturday)