For the HP-33S version, go here.
Written by Dave Coffin in March 2006.
These operations are useful for any problem that depends on the exact interval between two dates.
2006.0310 Today's date (Mar 10, 2006) XEQ C 732685 1965.0927 Your birthdate (Sep 27, 1965) XEQ C 717911 - 14774 Your age in days LASTx 717911 When will you be 20000 days old? 20000 + 737911 XEQ G 2020.063 FIX 4 2020.0630 June 30, 2020In my system, Day 0 is March 1, 0 A.D (better known as 1 B.C.), or Julian day 1721120. Thus at 12:00 noon Universal Time on March 10, 2006, the Julian day was 1721120 + 732685 = 2453805.0.
Divide a day number by seven and take the remainder to determine the weekday. Zero is Wednesday.
C01 LBL C C02 22 ; stash 0.88 for RCL+ later C03 25 C04 ÷ C05 STO Y C06 R↓ C07 ENTER ; copy the whole date C08 FP ; discard the year C09 0.0301 C10 x>y? ; move New Year's Day from January 1 to March 1 C11 RCL+ Y C12 x<>y C13 R↓ C14 - C15 STO Y ; save the new date C16 FP ; month and day in Xreg C17 STO- Y ; keep year only in Y C18 100 C19 × C20 ENTER ; split month and day C21 FP C22 100 C23 × C24 x<>y C25 IP ; Yreg = day, Xreg = month C26 153 ; convert month to days C27 × C28 5 C29 ÷ C30 2 C31 1/x C32 + C33 IP C34 + C35 365.25 ; convert year to days C36 RCL× Y C37 IP C38 + C39 RCL Y C40 100 ; centuries are not leap years... C41 ÷ C42 IP C43 - C44 LASTx ; ...except those divisible by 400 C45 4 C46 ÷ C47 IP C48 + C49 RTN checksum = 1058, length = 89.5
G01 LBL G G02 ENTER G03 ENTER G04 10 G05 × G06 9 G07 + G08 365242.5 ; how many whole centuries? G09 ÷ G10 IP ; add one missing leap day per century G11 + G12 LASTx ; except for centuries divisible by 400 G13 4 G14 ÷ G15 IP G16 - G17 ENTER G18 ENTER G19 10 G20 × G21 9 G22 + G23 3652.5 ; compute the year G24 ÷ G25 IP G26 STO Y G27 365.25 ; keep the remaining days G28 × G29 IP G30 - G31 2 ; determine month and day G32 1/x G33 + G34 5 G35 × G36 153 G37 ÷ G38 ENTER G39 FP G40 153 G41 × G42 5 G43 ÷ G44 IP G45 1 G46 + G47 100 G48 ÷ G49 x<>y G50 IP G51 + ; Xreg contains mm.dd G52 88 G53 x<> Y ; move New Year's Day from March 1 to January 1 G54 x<>y G55 10 G56 x≤y? ; "≤" means "less than or equal to" G57 RCL+ Y G58 + G59 7 G60 - G61 100 ; combine mm.dd value with year G62 ÷ G63 + G64 RTN checksum = 8A5D, length = 120.0