Skip to content
brickpool edited this page Apr 17, 2020 · 4 revisions

Miscellany

  • Weekday
    • Day of the week for any date since September 14, 1752

Source: HP-45 Applications Book (HP 00045-90320 Rev. B Reorder 00045-66001, Dec 1974)


Weekday

Day of the week for any date since September 14, 1752

d = day of month

m = month, with January and February beeing the 13th and 14th months of the previous year.

y = year (4 digits)

Weekday = (d + n1 + n2 - n3 + n4) mod 7

where n1 = Int(135·(m + 1))
n2 = Int(54·y)
n3 = Int(y100)
n4 = Int(y400)
Int is "integer part of".

Output is read as follows:
0 - Saturday
1 - Sunday
2 - Monday
3 - Tuesday
4 - Wednesday
5 - Thursday
6 - Friday

Example:
On what day was February 29, 1972?

Answer:
Tuesday (d=29, m=2, y=1972)

LINE DATA OPERATIONS DISPLAY REMARKS
1 d ENTER
2 m ENTER
3 y +> STO A R↓ ENTER
4 1/x 0 . 5 +
5 <+ INTG 6'IP f f is 1 if January or February, otherwise 0
6 +> STO - A January and February beeing the 13th
7 1 2 × + and 14th months of the previous year
8 1 + 1 3 ×
9 5 ÷ E1 Let e1=integer part of E1
10 <+ INTG 6'IP e1
11 + <+ x≶ A ENTER
12 ENTER ENTER 5 × 4
13 ÷ E2 Let e2=integer part of E2
14 <+ INTG 6'IP e2
15 RCL A + For 20th century date,
  go to 23
16 +> STO A R↓ 1
17 0 0 ÷ E3 Let e3=integer part of E3
18 <+ INTG 6'IP e3
19 +> STO - A R↓
20 4 0 0 ÷ E4 Let e4=integer part of E4
21 <+ INTG 6'IP e4
22 RCL A + Go to 24
 
23 6 +
24 7 RMDR w Remainder part of the integer division by 7