1
$\begingroup$

This question already has an answer here:

How to find the week day of any given date?

Say we need to know in which week-day was June $25,2019$?

$\endgroup$

marked as duplicate by John Omielan, José Carlos Santos, Lee David Chung Lin, YuiTo Cheng, The Count Jun 27 at 1:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1
$\begingroup$

To determine the week-day of a given date, we need to:

  • find out whether the given year is "common" or "leap".

  • know $\mod(a,b)$.

  • know $\left \lfloor a \right \rfloor$.


To find out whether the given year is "common" or "leap", we can use the following chart:

enter image description here

$\mod(a,b)$ means the remainder when dividing $a$ by $b$. For example, when we divide $17$ by $3$, we get $5$ and the remainder is $2$. Therefore, $\mod(17,3)=2$.

For convince, $\mod(a,100)=$ the number formed by the last two digits of $a$. For example, $\mod(13527,100)=27$.


$\left \lfloor a \right \rfloor$ means the nearst integer less than or equal to $a$. For examples,

$\left \lfloor 6.97 \right \rfloor=6$,$\left \lfloor -2.8 \right \rfloor=-3,\left \lfloor \frac{20}{4} \right \rfloor=5$.


Suppose that the given date is of the form: MONTH $d, y$

We have to calculate the following:

  • $A=\mod(y,100)$

  • $B=\left \lfloor \frac{A}{4} \right \rfloor$

  • $C=\frac{y-A}{100}$

  • $D = d$ which is the given date.

  • $E =\left \lfloor \frac{C}{4} \right \rfloor$

  • $F=0,3,2,5,0,3,5,1,4,6,2,$ or $4$ depending on the given month (Jan, Feb, March, ..., or Dec) respectively.

  • $G=\left\{\begin{matrix} 0 & \text{if the month is not Jan nor Feb}\\ 1 & \text{for Jan or Feb in a common year}\\ 2 & \text{for Jan or Feb in a leap year} \end{matrix}\right.$

  • $H=\mod(A+B-2C+D+E+F-G,7)$

  • The week-day depends on the $H$ value, $0$ for Sunday, $1$ for Monday, $2$ for Tuesday, $3$ for Wednesday, $4$ for Thursday, $5$ for Friday, and $6$ for Saturday.


Consider the example, June $25,2019$

Since $2019$ is not divisible by $4$, then $2019$ is a common year.

$A=\mod(2019,100)=19$

$B= \left \lfloor \frac{19}{4} \right \rfloor=4$

$C=\frac{2019-19}{100}=20$

$D= 25$ as given.

$E= \left \lfloor \frac{20}{4} \right \rfloor=5$

$F=3$ for June.

$G=0$ since the given month is neither Jan nor Feb.

$H=\mod(19+4-2\times20+25+5+3-0,7)=\mod(16,7)=2=$ Tuesday.


I noticed that many people ask about this. I posted this way because I think it is the simplest way for any given date , whatever the given century.

There are some simpler ways but for years between 2000 and 2099 only.

So it is a general way.

If you know any simpler way than this, please leave a comment or just post it as an answer, THANKS!.

This may be a useful page for you: https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week

$\endgroup$
  • $\begingroup$ I believe your algorithm for determining if a year is leap is wrong, given that a year divisible by 4 and not by 100 should be a leap year $\endgroup$ – karmalu Jun 26 at 16:45
  • $\begingroup$ @karmalu I did not get your point dear. May you clarify that, please? $\endgroup$ – Hussain-Alqatari Jun 26 at 16:59
  • $\begingroup$ If i understand correctly the chart you posted it seems that a year that is divisible by 4 and not by 100 like 2020 should be common while, in fact, it will be a leap year. $\endgroup$ – karmalu Jun 26 at 17:04
  • $\begingroup$ @karmalu You are right! I will correct the chart and will edit it. Thanks. $\endgroup$ – Hussain-Alqatari Jun 26 at 17:07
  • $\begingroup$ @karmalu Can you please check my edit to the chart? $\endgroup$ – Hussain-Alqatari Jun 26 at 17:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.