Day of the Week Formula

Dec 05, 2006 08:49

You can find the name of the day of the week of day. Next time you bored and you want to know the name of the day of the week and don't know how to use a calendar or lost your calendar b/c you left it with your bicycle, you can use this.

a = (14-month) / 12
y = year - a
m = month + 12a - 2
d = (day + y + (y/4) - (y/100) + (y/400) + (31m/12) mod 7

d = 0 is Sunday, d = 1 is Monday, d = 2 is Tuesday, d = 3 is Wednesday, d = 4 is Thursday, d = 5 Friday, d = 6 Saturday

To find which day of the week December 25th 2006 will be on.

a = (14 - 12) / 12
y = 2006 - (14 - 12) / 12
m = 12 + (12 * (14 - 12) / 12) - 2
d = (25 + (2006 - (14 - 12) / 12) + ((2006 - (14 - 12) / 12) / 4) - ((2006 - (14 - 12) / 12) / 100) + ((2006 - (14 - 12) / 12) / 400) + ((31 * (12 + (12 * (14 - 12) / 12) - 2)) / 12)) mod 7
d = 2542 mod 7
Solve: 2542 mod 7
2542 / 7 = 363 R 1 (check 363*7 = 2541 so 2541+1 = 2542)
d = 1

1 = Monday so
Monday, December 25th 2006
dies lunae ante diem VIII Kalends Ianuarius MMVI
Previous post Next post
Up