Day of the week

### 7.1.28 Day of the week

The dayofweek command finds the day of the week for any date after 15 October 1582.

- dayofweek takes as arguments three arguments:
  - d, an integer representing the day of the month.
  - m, an integer representing the month.
  - y, an integer representing the year.
  The date represented should be after 15 October 1582.
- dayofweek(d,m,y) returns an integer from 0 to 6 (0=Sunday, 1=Monday, …).

#### Examples

dayofweek(1,10,2014)

3 |  |  |  |  |  |  |  |  |  |

This means that 1 October, 2014 was a Wednesday.

dayofweek(15,10,1582)

5 |  |  |  |  |  |  |  |  |  |

This indicates that 15 October 1582 was on a Friday.

##### Historical note.

The Gregorian calendar, the calendar used by most of the world, was introduced on 15 October 1582. Before that, the Julian calendar was used, which had a leap year every four years and so used years with an average of 365.25, which is slightly off from the actual value of about 365.242 days. To deal with this, the Gregorian calendar was introduced, where a leap year is a year which is divisible by 4, but not divisible by 100 unless it is also divisible by 400. This gives an average length of year that is accurate to within 1 day every 3000 years. Many countries switched from the Julian calendar to the Gregorian calendar after 4 October 1582 in the Julian calendar, and the next day was 15 October 1582.