Zeller’s Rule : With this technique named after its founder Zeller, you can solve any ‘Dates and Calendars’ problems.
Zellers rule can be used to find the day on any particular date in the calendar in the history. All you have to know is the formula given below and how to use it.
Zeller’s Rule Formula:
F = K + [(13xM – 1)/5] + D + [D/4] + [C/4] – 2C
K = Date => for 25/3/2009, we take 25
In Zeller’s rule months start from march.
M = Month no. => Starts from March.
March = 1, April = 2, May = 3
Nov. = 9, Dec = 10, Jan = 11
Feb. = 12
D = Last two digits of the year, using previous year for January and February. Thus for 2009 = 09
C = The first two digits of century => for 2009 = 20
Example: 25/03/2009
F = 25 + [{(13 x1)- 1}/5] + 09 + 09/4 + 20/4 – (2 x 20)
= 25 + 12/5 + 09 + 09/4 + 20/4 – 2×20
=25+2+09+2+5-40 [ We will just consider the integral value and ignore the value after decimal]
= 43 – 40 =
Replace the number with the day using the information given below.
1 = Monday
2 = Tuesday
3 = Wednesday
4 = Thursday
5 = Friday
6 = Saturday
7 or 0 = Sunday
So it’s Wednesday on 25th march, 2009.
If the number is more than 7, divide the no. by 7. The remainder will give you the day.
I shall be very grateful if anyone of you can provide me the java script for this formula, so that I can post it here for everyone’s convenience.
Thanks in advance. I hope you will find the above method very useful.
you may find another post named, cyclicity very interesting.
Vineet Patawari – PGDM, ACA, B.COM (H)
Hey I made a codepen based on this if someone needs it
https://codepen.io/-z-/pen/XPgvpG?editors=1010
For 08-01-2029 the actual day is Monday
And by using Zellers rule the answer is Tuesday
Please help me out
Yes because you might have taken D=18 as last two digits of year but in this case it should be D=18-1=17 because we are considering that our year starts from march and ends in february ..So if we are given jan/feb months than in those cases D =last two digits-1 . I hope It works.
I can’t find
1 Jan 1600 through it please give solution about this
pls take out 18 dec. 1991
18+((13*10-1))/5+91+91/4+19/4-19*2
18+129/5+91+22+4-38
18+25+91+22+4-38
122
122/7. 3 remaining
Ans: Wensday
Solution
18+((13*10-1))/5+91+91/4+19/4-19*2
18+129/5+91+22+4-38
18+25+91+22+4-38
122
122/7. 3 remaining
Ans: Wensday
for an leap year of jan and feb this formula is wrong
for an leap year of jan and feb this formula is wrong
for an leap year of jan and feb this formula is wrong
This is right formula… frnd
Sir,
I want to know short cut to find date.
Here the question is: what will be the date after 73days from 23rd September 2017
Add 7 days to 23rd September……now remaining days 66…..subt 31 days for oct and 30 for nov respectively …..now left days 5 . So it will be 5th dec
Sir,plss find the day of week on 15th august 1947
i could find the day of 14th Jan 2001. Please help me how to do
Answer for 14 jan 2001
Put this in zeller’s rule ….we get
14 + (13*11-1)/5 + 00 + 00/4 + 5 – 40
= 14+28+5-40
=7 now divide by 7
=0 i.e. sunday
can u pla explain what day was 1st jan 2000
Answer for 14 jan 2001
Put this in zeller’s rule ….we get
14 + (13*11-1)/5 + 00 + 00/4 + 5 – 40
= 14+28+5-40
=7 now divide by 7
=0 i.e. sunday
For 1st jan 2000 ….put 1999 instead 2000 u will get ur answer…..bcoz u hv to subtract 1 for jan & feb month from the given year
“””implementation of Zeller’s Equation to calculate day of week for a given date using python.
Its modified for convenience of people.You can take jan=1,feb=2…so on.It can take input in any of the following forms :
13-Jan-2015 or 13-01-2015
13/Jan/2015 or 13/1/2015
13,Jan,2015 or 13,1,2015
Note:for any month use 3 letter short-form with initial letter capitalised. e.g. Jan, Apr etc.
Implementation is in Python 3
————————————————————————–
“””
from enum import Enum
class days(Enum):
Sunday=0
Monday=1
Tuesday=2
Wednesday=3
Thursday=4
Friday=5
Saturday=6
class months(Enum):
Jan=1
Feb=2
Mar=3
Apr=4
May=5
Jun=6
Jul=7
Aug=8
Sep=9
Oct=10
Nov=11
Dec=12
def findDayOfWeek(day,month,year):
if(month.isalpha()):
month=months[month].value
K=int(day)
if(int(month)-2<=0):
M=int(month)+10
else:
M=int(month)-2
if(M==11 or M==12):
year=str(int(year)-1)
C=int(year[0:2])
D=int(year[2:])
return (K+int((13*M-1)/5)+D+int(D/4)+int(C/4)-2*C)%7
date=input().strip()
if "/" in date:splitter="/"
elif "-" in date:splitter="-"
else:splitter=","
(day,month,year)=date.split(splitter)
x=findDayOfWeek(day,month,year)
print(days(x).name)
#Code ends here.
"""
—————————————————-
"""
THIS IS A BETTER CODE FOR ZELLER RULE USING PYTHON
THIS IS MADE BY A 14 YEAR OLD CODER WITH BASIC KNOWLEDGE OF PYTHON
I HAVE LEARNT IT IN THE 2ND MODULE OF PYTHON LEARNING ON SOLOLEARN APP
REPLY TO PRESENT YOUR VIEWS
—————————————————
i=0
while i==0:
print(“DATE TO DAY CONVERTER”)
date = int(input(“ENTER A DATE (DD) “))
month = int(input(“ENTER THE MONTH NUMBER(MM) “))
yearcent = int(input(“ENTER THE 1ST 2 DIGITS OF THE YEAR (YY–) “))
yearaft = int(input(“ENTER THE LAST 2 DIGITS OF THE YEAR (–YY) “))
RISHIMA=[11,12,1,2,3,4,5,6,7,8,9,0]
monthno=0
monthno=int(RISHIMA[month-1])
if month==1 or month==2:
if yearaft==00:
yearaft=99
else:
yearaft=yearaft-1
monthfunc=int((13*monthno-1)/5)
day=date+monthfunc+yearaft+int(yearaft/4)+int(yearcent/4)-(2*yearcent)
while day=7:
day=day%7
PRAGYANSH=[“SUNDAY”,”MONDAY”,”TUESDAY”,”WEDNESDAY”,”THURSDAY”,”FRIDAY”,”SATURDAY”]
print (PRAGYANSH[day])
x=input(“DO YOU WANT TO QUIT (y/n) “)
if x==”y”:
print(“THANKS FOR USING ME ;)”)
break
else:
print(“LETS DO IT ALL AGAIN”)
———————————————————–
CODE ENDED
ITS IN AN OPTIONAL LOOP
DATE TO DAY CONVERTER V2
NOW INPUTS DATA IN DD/MM/YY, DD.MM.YY, DD,MM,YY AND ANY FORMAT
————————————————————————————
i=0
while i==0:
print(“DATE TO DAY CONVERTER”)
mum=input(“INPUT A DATE IN DD/MM/YYYY FORMAT “)
date= int(mum[0]+mum[1])
month=int(mum[3]+mum[4])
yearcent=int(mum[6]+mum[7])
yearaft=int(mum[8]+mum[9])
RISHIMA=[11,12,1,2,3,4,5,6,7,8,9,0]
monthno=0
monthno=int(RISHIMA[month-1])
if month==1 or month==2:
if yearaft==00:
yearaft=99
else:
yearaft=yearaft-1
monthfunc=int((13*monthno-1)/5)
day=date+monthfunc+yearaft+int(yearaft/4)+int(yearcent/4)-(2*yearcent)
while day=7:
day=day%7
PRAGYANSH=[“SUNDAY”,”MONDAY”,”TUESDAY”,”WEDNESDAY”,”THURSDAY”,”FRIDAY”,”SATURDAY”]
print (PRAGYANSH[day])
x=input(“DO YOU WANT TO QUIT (y/n) “)
if x==”y”:
print(“THANKS FOR USING ME ;)”)
break
else:
print(“LETS DO IT ALL AGAIN”)
———————————————————————–
END OF CODE
ENJOY THE VERSION 2 CODE
DATE TO DAY CONVERTER V3
NOW WITH ERRORCHECKS
————————————————————-
i=0
while i==0:
print(“DATE TO DAY CONVERTER V3”)
print(“VERSION UPDATES :”)
print(“18/02/2017 16:57 V3 : ADDED ERRORCHECKS”)
print(“18/02/2017 16:40 V2 : ADDED DD/MM/YY INPUT”)
mum=input(“INPUT A DATE IN DD/MM/YYYY FORMAT “)
if len(mum)==10:
date= int(mum[0]+mum[1])
month=int(mum[3]+mum[4])
yearcent=int(mum[6]+mum[7])
yearaft=int(mum[8]+mum[9])
RISHIMA=[11,12,1,2,3,4,5,6,7,8,9,0]
monthno=0
monthno=int(RISHIMA[month-1])
if month==1 or month==2:
if yearaft==00:
yearaft=99
else:
yearaft=yearaft-1
monthfunc=int((13*monthno-1)/5)
day=date+monthfunc+yearaft+int(yearaft/4)+int(yearcent/4)-(2*yearcent)
while day=7:
day=day%7
PRAGYANSH=[“SUNDAY”,”MONDAY”,”TUESDAY”,”WEDNESDAY”,”THURSDAY”,”FRIDAY”,”SATURDAY”]
print (PRAGYANSH[day])
x=input(“DO YOU WANT TO QUIT (y/n) “)
if x==”y”:
print(“THANKS FOR USING ME ;)”)
break
elif x==”n”:
print(“LETS DO IT ALL AGAIN”)
else:
print(“INVALID INPUT…….”)
print(“CONTINUING THE PROGRAM…….”)
else:
print(“INVALID INPUT”)
———————————————————————
CODE ENDED
ITS IN AN OPTIONAL LOOP
MADE BY A 14 YEAR OLD CODER
Plz calculate day 29 feb 1992…
For jan and feb …. subtract 1 from the given year…..and putthe values in zeller’s formula.
You’llget ur answer
Plz calculate day 29 feb 1992…
I want the solution of 27th sept 1973
please show the calculation for 3/3/89…
thanks
3+(13*1-1)/5+89+89/4+19/4-38
==> 3+2.4+89+22.25+4.75-38
=3+2+89+22+4-38
=82/7
=5 remaining days. I.e friday
sirra formula.great formula
Hi,
In response to “I shall be very grateful if anyone of you can provide me the java script for this formula, so that I can post it here for everyone’s convenience.”
Today I just read the Zeller’s Rule from ur blog and have build a js code for u.
I need ur email Id.
I see a lot of interesting articles on your blog.
You have to spend a lot of time writing, i know how to save you a lot of time, there is a tool that creates unique,
SEO friendly articles in couple of minutes,
just type in google – laranita’s free content source
The formula does not work for the dates Sept 3, 1752 – Sept 13, 1752. This is when the Gregorian calendar was changed. Please explain.
The Gregorian calendar was instituted on AD 1582 Oct 15th.
and 1752 Sep 13 was on wed day.
The formula is not working for Sept 3 – Sept 13. These dates were eliminated during that calendar year. Explain please.
at last i have got solution. really it is a awesome work. it should be given a thanks to admin for the demonstration
hello!,I like your writing so a lot! share we be in contact extra about your post on AOL? I need a specialist on this house to resolve my problem. May be that is you! Looking ahead to peer you.
Its not working for 16/01/1988. I am getting it Wednesday!!
(28+16+87+21+4-38)mod 7=6. It is Saturday.
1988 was leap year .and Jan 1st was on Friday. And Jan 8th and Jan 15th also on Friday. So Jan 16th was on Satur day.
16+(13*11-1)/5+87+21+19/4-38
16+28+87+21+4-38
=118/7
=6 day remaining i.e. Saturday
This is very informative though some are difficult.
thank you
31/08/1990 it is friday but i’m getting wrong answer………. once try..
(31+15+90+22+4-38)mod 7+5. This is Friday
31+(13*6-1)/5+90+90/4+19/4-38
=31+15+90+22+4-38
=124/7
=5 remaining days i.e. Friday
not workin for
26 jan 1952
itz saturday on tht day…..0 or 7 shud come..
bt
1is comin.
( REPLY )
It is working. Above the extra rule is forgotten: If you have to determine a date in January (M = 11) or February (M = 12) it belongs to the prior year.
So in the above case C = 51 (and not 52!).
bro… its not C
its D=51 (since its jan)
C will remain same i.e 19
its working man..
1988 was leap year .and Jan 1st was on Friday. And Jan 8th and Jan 15th also on Friday. So Jan 16th was on Satur day.
I prepared such a book named CALENDAR R FOR EVER form which you can find out any day of any date since the Gregorian Calendar was institued.
and if u have some time please visit http://www.splmaths.worpress.com
Hey buddy i wrote the java code but oit is not working for the jan feb and march remaining all r fine i’m sending u the code lets c wat u can say abt the code and do reply me on raj.tvss@gmail.com or u can message me on 7204974366 i’m resedent of bangalore and here is the code
CODE:
import java.util.Scanner;
import java.*;
public class Date{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int d,c,day;
//
// Read year
//
System.out.print(“Year: “);
int y = scanner.nextInt();
// Read date
System.out.print(“Date: “);
int k = scanner.nextInt();
//
// Read month
//
System.out.print(“Month in numeric formate: “);
int m = scanner.nextInt();
switch (m)
{
case 1: m=11;
break;
case 2: m=12;
break;
case 3: m=1;
break;
case 4: m=2;
break;
case 5: m=3;
break;
case 6: m=4;
break;
case 7: m=5;
break;
case 8: m=6;
break;
case 9: m=7;
break;
case 10: m=8;
break;
case 11: m=9;
break;
case 12: m=10;
break;
}
d=y%100;
c=y/100;
day = k*((13*(m-1))/5)+d+(d/4)+(c/4)-2*c;
//System.out.println(“Day is”+day);
if (day<0)
{
int day1 = -(day);
int div = day1/7;
int rem = 7*(div+1)+day;
day=rem;
}
else
{
day=day%7;
}
switch (day)
{
case 0: System.out.print("The Given Date is a "+"Sunday");
break;
case 1: System.out.print("The Given Date is a "+"Monday");
break;
case 2: System.out.print("The Given Date is a "+"Tuesday");
break;
case 3: System.out.print("The Given Date is a "+"Wednesday");
break;
case 4: System.out.print("The Given Date is a "+"Thursday");
break;
case 5: System.out.print("The Given Date is a "+"Friday");
break;
case 6: System.out.print("The Given Date is a "+"Satday");
break;
}
}
}
USE PYTHON CODE——————————-
BY A 14 YEAR OLD———————-
——————————————————-
THIS IS A BETTER CODE FOR ZELLER RULE USING PYTHON
THIS IS MADE BY A 14 YEAR OLD CODER WITH BASIC KNOWLEDGE OF PYTHON
I HAVE LEARNT IT IN THE 2ND MODULE OF PYTHON LEARNING ON SOLOLEARN APP
REPLY TO PRESENT YOUR VIEWS
—————————————————
i=0
while i==0:
print(“DATE TO DAY CONVERTER”)
date = int(input(“ENTER A DATE (DD) “))
month = int(input(“ENTER THE MONTH NUMBER(MM) “))
yearcent = int(input(“ENTER THE 1ST 2 DIGITS OF THE YEAR (YY–) “))
yearaft = int(input(“ENTER THE LAST 2 DIGITS OF THE YEAR (–YY) “))
RISHIMA=[11,12,1,2,3,4,5,6,7,8,9,0]
monthno=0
monthno=int(RISHIMA[month-1])
if month==1 or month==2:
if yearaft==00:
yearaft=99
else:
yearaft=yearaft-1
monthfunc=int((13*monthno-1)/5)
day=date+monthfunc+yearaft+int(yearaft/4)+int(yearcent/4)-(2*yearcent)
while day=7:
day=day%7
PRAGYANSH=[“SUNDAY”,”MONDAY”,”TUESDAY”,”WEDNESDAY”,”THURSDAY”,”FRIDAY”,”SATURDAY”]
print (PRAGYANSH[day])
x=input(“DO YOU WANT TO QUIT (y/n) “)
if x==”y”:
print(“THANKS FOR USING ME ;)”)
break
else:
print(“LETS DO IT ALL AGAIN”)
———————————————————–
CODE ENDED
ITS IN AN OPTIONAL LOOP
it just a logical works
18+{(13*12-1/5)}+91+91/4+19/4-38
=18+35+91+22+4-38=132
132/7 now remainder=6 implies thd day is saturday
Dear Quicker Maths,
How to Calculate the days of the week for a following date:
1. 7th Dec, 1941
2. 16th Apr, 2000
3. 1st Jan, 2004
4. 8th March, 2005
5. 26th Jan, 1950
etc
how to calculate if the remainder is zero.
if remainder is 0 than we can take remainder =7
how to calculate dates between 2000 to 2004
very nice trick But I want to find out days between 2000 to 2009
sir its coming wrong for 18/2/1991 please give the corrected formula
not workin for
28/02/2010
itz sunday on tht day…..0 or 7 shud come..
bt
1 is comin.
according to Zellers rule,the last two digits of the year should be 1 less than that of the year i for any dates on the months january and february.
In case of negative f, simply add a big multiple of 7 (say 70) to f and check for the remainder.
For ex: f= -17
-17 + 70 = 53
Divide 53 by 7 to get remainder of 4.
Dear, friends thanks for the great discussion and comments!
@Bharat: Thanks for explaining the whole thing in your own words. From our side we tried to keep it as simple as possible. Thanks for including the explanation for negative ‘f’.
Just to remove any error in your explanation I would like to point out this, “so -3 + 6 is again a remainder of 4.” which seems wrong. Please confirm.
Thanks anyway for your contribution!
its actually not explained proprrlyy hav a luk below 2 get the corrrect idea n mahesh ur query will also be solved …
The following formula is named Zeller’s Rule after a Reverend Zeller. [x] means the greatest integer that is smaller than or equal to x. You can find this number by just dropping everything after the decimal point. For example, [3.79] is 3. Here’s the formula:
f = k + [(13*m-1)/5] + D + [D/4] + [C/4] – 2*C.
k is the day of the month. Let’s use January 29, 2064 as an example. For this date, k = 29.
m is the month number. Months have to be counted specially for Zeller’s Rule: March is 1, April is 2, and so on to February, which is 12. (This makes the formula simpler, because on leap years February 29 is counted as the last day of the year.) Because of this rule, January and February are always counted as the 11th and 12th months of the previous year. In our example, m = 11.
D is the last two digits of the year. Because in our example we are using January (see previous bullet) D = 63 even though we are using a date from 2064.
C stands for century: it’s the first two digits of the year. In our case, C = 20.
Now let’s substitute our example numbers into the formula.
f = k + [(13*m-1)/5] + D + [D/4] + [C/4] – 2*C
= 29 + [(13*11-1)/5] + 63 + [63/4] + [20/4] – 2*20
= 29 + [28.4] + 63 + [15.75] + [5] – 40
= 29 + 28 + 63 + 15 + 5 – 40
= 100.
Once we have found f, we divide it by 7 and take the remainder. Note that if the result for f is negative, care must be taken in calculating the proper remainder. Suppose f = -17. When we divide by 7, we have to follow the same rules as for the greatest integer function; namely we find the greatest multiple of 7 less than -17, so the remainder will be positive (or zero). -21 is the greatest multiple of 7 less than -17, so the remainder is 4 since -21 + 4 = -17. Alternatively, we can say that -7 goes into -17 twice, making -14 and leaving a remainder of -3, then add 6 since the remainder is negative, so -3 + 6 is again a remainder of 4.
A remainder of 0 corresponds to Sunday, 1 means Monday, etc. For our example, 100 / 7 = 14, remainder 2, so January 29, 2064 will be a Tuesday.
Sir,
How to find the days by using Zeller’s Rule Formula for the year 2010 ,This Zeller’s Rule is applicable only for the year 2009,but the answer is not coming for the other years…
plz send the correct solution to find the day for other years..
Thank u for finding the answer for year 2009
it will be really great if u help us in explaining the logic behind this formula…
Very well organized formula ..
especially, the leap year part, I Liked the most…
Thanks Abhimanyu
Can u explain for leap year 1 Jan 2000 is not working
can u pla explain what day was 1st jan 2000
informative but little difficult