### Srinisspace - Day finder – Math Magic

When I was a kid, I learned a method to calculate the day of a week for any given date from an article in ‘The Hindu’. It consists of a simple formula and calculations. Only one difficult part is to remember a sequence of letters to find the week with respect to the month.

Each word stands for their respective day in a week,

In this post, we will see how to calculate the day using today’s date.

Let's take 23rd Aug 2019

The formula to find the day is D+Y+Q(Y/4)-2R(C/4)

D – Date; Y – Year(last two-digit) ; C – Century of the year(first two-digit); Q – Quotient; R – Reminder

If we apply the formula,

23+19+Q(19/4)-2*R(C/4) = 42+4-(2*0) = 46

Now, we have to divide this answer with 7 and find the Reminder.

R(46/7) = 4

Now we have to apply this number to the above table for the particular month,

We are in August and in that table, Aug starts with M(Monday). So we have to start M with 0 and proceed till the remainder value we got in the above step,

```Monday    - 0
Tuesday   - 1
Wednesday - 2
Thursday  - 3
Friday    - 4 ```

So the day on 23rd August is Friday.

For Jan and Feb we have two starting values, the first one is for Leap year and the Second one is for Non-Leap year. If you want to find a day which falls on Leap year Jan, then you have to use the first value F(Friday) and if it is a non leap year then you have to start with S(Saturday)

Let's take another example from the 19th century for leap year and try to solve it,

Let's take 10th Jan of 1940

```D+Y+Q(Y/4)-2R(C/4) = 10+40+Q(40/4)-(2*R(19/4))
= 10+40+10-(2*3)= 60-6
= 54
R(54/7) = 5```

It is on Leap year January and so we have to start with Friday

```Friday    - 0
Saturday  - 1
Sunday    - 2
Monday    - 3
Tuesday   - 4
Wednesday - 5```

The day of 10th Jan 1940 is Wednesday.

You can try this formula to find day for any date in the Gregorian calendar.