HP Forums
(17Bii) Finding the first Advent Sunday in a year - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (17Bii) Finding the first Advent Sunday in a year (/thread-14150.html)



(17Bii) Finding the first Advent Sunday in a year - jthole - 12-11-2019 10:27 AM

This simple equation returns the date of the first Advent Sunday in a year. For some background info about the Advent period: https://en.wikipedia.org/wiki/Advent

ADVDATE = DATE( L( XMAS : ( YEAR ÷ 1000000 + 25.12 ) ) : RND( ( 7 x FP( DDAYS( 1.0119 : G( XMAS ) : 1 ) ÷ 7 ) + 22 ) x - 1 : 0 ) )

You enter the year, e.g. 2021, and the returned date is (dd.mmyyyy) 28,112021.

Another example: year 2025 returns 30,112025.

Edit: obviously this doesn't work for dates before January 1, 1900 Wink


RE: (17Bii) Finding the first Advent Sunday in a year - jthole - 12-11-2019 12:34 PM

Here is a shorter (and slightly improved) solution, thanks to Dave Britten:

ADVDATE = DATE( L( XMAS : YEAR ÷ 1000000 + 25.12 ) : ( ( MOD( DDAYS( 1.011582 : G( XMAS ) : 1 ) : 7 ) + 22 ) x - 1 ) )

Edit: I just realised you could write an even much simpler solution; you just have to find the closest Sunday to November 30.