|
What day of the week will May 12, 2037 be? What day of the week was September 17, 1004?
Here is a neat algorithm that will tell you:
[NOTE:- All divisions, except where noted otherwise, are integer divisions, in which remainders are discarded.] First figure out the values for "a", "y" and "m"-- variables to be plugged into a formula.
a = (14 - month)/12
y = year - a
m = month + 12a - 2
Next, plug the values of "y" and "m" into the following formula to calculate the day:
d = (day + y + y/4 - y/100 + 31m/12) mod 7
The answer you get for "d" will correspond to a day of the week such as: 0 = Sunday. 1 = Monday. 2 = Tuesday. 3 = wednesday. 4 = Thursday. 5 = Friday. 6 = saturday.
Let's work an example, shall we? What day of the week will April 5, 2020 fall on?
First figure out "a", "y" and "m":
a = (14 - 4)/12 = 0
y = 2020 - 0
m = 4 + 12(0) - 2 = 2
Now plug "y" and "m" into the "d" formula to calculate the day:
d = (5 + 2020 + 2020/4 - 2020/100 + 2020/400 + 31(2)/12) mod 7
d = (5 + 2020 + 505 - 20 + 5 + 5) mod 7
d = 2520 mod 7
d = 0
Recall from above that 0 = SUNDAY. So April 5, 2020 will be a Sunday.
Remember, you can do this for dates in the past as well. If you need any help in understanding the above algorithm, please E-Mail me (given below)
|
| (c) Bheshaj Kumar Ashley Hoolash |