### [DM41][HP 17Bii] Date of the first advent Sunday in a year

Posted:

**Tue Feb 04, 2020 10:12 pm**This small program is an adaptation of an equation I have in my HP 17Bii. One of the reasons for posting this here, is that it shows the elegance of the HP 17Bii solver. The other reason is that it's fun, and can be useful (if only because you know when to open the first window of the Advent calendar ).

First of all, here is the short and simple HP 17Bii Solver equation: (both the solver and program assume DD.MMYYYY).
And here is the DM41 program, which takes the year in the X register (just following the equation; maybe could be optimised further).
Running on the HP 17Bii:

Enter YEAR: 2021

Solve ADVDATE: 28,112021

Running on the DM41L:

2021

XEQ ADVDATE

28,112021

Of course, the program (and equation) only works for the Gregorian calendar. Monday Jan. 1, 1900 was chosen because I liked that date (any date works, as long as you adjust the offset (currently 22) in the equation.

First of all, here is the short and simple HP 17Bii Solver equation: (both the solver and program assume DD.MMYYYY).

Code: Select all

```
ADVDATE = DATE( L( XMAS : YEAR รท 1000000 + 25.12 ) : ( ( MOD( DDAYS( 1.0119 : G( XMAS ) : 1 ) : 7 ) + 22 ) x - 1 ) )
```

Code: Select all

```
LBL "ADVDATE"
1000000
/
25.12
+
STO 00
1.0119
X<>Y
DDAYS ;XROM 26,14
7
MOD
22
+
CHS
RCL 00
X<>Y
DATE+ ;XROM 26,13
END
```

Enter YEAR: 2021

Solve ADVDATE: 28,112021

Running on the DM41L:

2021

XEQ ADVDATE

28,112021

Of course, the program (and equation) only works for the Gregorian calendar. Monday Jan. 1, 1900 was chosen because I liked that date (any date works, as long as you adjust the offset (currently 22) in the equation.