Saturday, May 23, 2015

Finding day for a given date part-1 (for dates between year 2000 to 2099)

We can find day for a given date. Steps are given below

First find Day-sum and then divide this by 7 and remainder is day code (0 for Sunday and 6 for Saturday starting). 

Day-sum =  year code+month code+Date.
Year code for 2015 is 4 and  Month code from Jan to Dec are 622 503 514 624 .

Let us find the day for 23 May 2015 
Year code is 4, month code 0 and date is 23rd
Day-sum is 4+0+23 = 27,  divide 27 by 7 and remainder is 6 and hence 23rd May is Saturday.

31st Dec 2015
Day-sum is 4+4+31 = 39, Divide 39 by 7 and the remainder is 4 and hence the day is Thursday

Finding year code : Value  for year 2000  is zero and and for subsequent years we add 2 digit of year code by number of leap years and divide by 7 and the remainder is year code for the year.
For year 2015 - leap years are 3 ( 15/4 ) and hence year value is  15+3=18 and divide 18 by 7 and the remainder is 4 which is the year code for 2015.



Year code for 2014 is (14+3) is 17 and dividing 17 by 7 we get remainder as 3 which is the year code for 2014,

Year code for 2042 is (43+10) is 53 and dividing  by 7 we get remainder as 4 which is the year code for 2043.

LEAP YEAR - For 2016 year code is 16+4=20, divide 20 by 7 and value is 6 but  for Jan & Feb we subtract 1 being leap year. So for Jan & Feb the year code is 5 and for rest of the month it is 6.

let us find days for some dates in year 2016 being a leap year.
2nd Jan 2016 ; We will take year code as 5 (6-1) being a leap year,  Day-sum is 5+6+2=13. Divide 13 by 7 and remainder is 6 and hence Saturday
31st March 2016 ; For march year code is 6, Day-sum is 6+2+31=39 and divide by 7 and remainder is 4 thus Thursday.



No comments:

Post a Comment