Have you ever wondered if your next birthday will be on a weekend? Well we have a magical formula to find the day on which a day falls! Check it out below.
D = ( [23/9*m] + d + 4 + y + [z/4] - [z/100] + [z/400] - 2 {if m >= 3}) mod 7
If m < 3 then z = y - 1 else z = y
The square brackets [] indicate that when you have calculated what is inside the brackets then ignore any fractional value after the decimal point. Mod gives remainder. For example 12 mod 5 is 2.
Here D rrepresents the value of the day. D = 0 means Sunday, D=2 means Tuesday and so on. y is the Year, m the month and d the day.
Let's do the calculations for Feb 28th 2011. In this case m=3 since February is the 2nd month, d=29 and y=2011. So calculation gives (5+28+4+2011+502-20+5) mod 7 = 1 which means it falls on Monday.
Now isn't it worth learning and sharing?