Time & Calendar
Intermediate

Day of the Week from a Birthdate

Gauss's weekday formula — find which day of the week any birthdate fell on.

Formula

W=(d+2.6m0.2+y+y4+c42c)mod7W = \left(d + \left\lfloor 2.6m - 0.2 \right\rfloor + y + \left\lfloor\tfrac{y}{4}\right\rfloor + \left\lfloor\tfrac{c}{4}\right\rfloor - 2c\right) \bmod 7

Variables

dDay of month
mMonth (Mar=1 … Dec=10, Jan=11, Feb=12 of prior year)
yYear within century
cCentury
W0=Sun,1=Mon,…,6=Sat

Example

15 Aug 1947 → W = 5 ⇒ Friday

Did You Know?

Isaac Asimov reportedly could name the weekday of any date in his head; the trick is exactly this kind of modular arithmetic.