Problem Doomsday formula (converted from Python)

ChristinaBB

New Member
Joined
Nov 23, 2010
Messages
6
I am trying to convert the following Python Algoritm (source: Algorithm on how to find the day of a week):
day_of_week(year, month, day):
t = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]
year -= month < 3
return (year + int(year/4) - int(year/100) + int(year/400) + t[month-1] + day) % 7

to an excel formula, but the result comes out wrong:
I'm calculating the day (0=Sunday) as: =MOD(year+INT(year/4)-INT(year/100)+INT(year/400)+OFFSET(t,IF(Adj_month=0,12,Adj_month-1),0)+Day,7)
Adj_month=Month+IF(Month<3,-1)-1

And t is the top value in this list:
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Sorry, the question was posted with out the t-list: here it is:
0​
3​
2​
5​
0​
3​
5​
1​
4​
6​
2​
4​

The value come out incorrectly, e.g. for 1900-02-28 which should be a Wednesday, but my formula returns Monday.
Can anyone help me with this?
(I tried to use the upload mini-sheet function, but my excel really did not like it )
 

Attachments

  • mrexcel error message.JPG
    mrexcel error message.JPG
    24.6 KB · Views: 8
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top