(32SII) Day Number of the 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: (32SII) Day Number of the Year (/thread-486.html) (32SII) Day Number of the Year - Eddie W. Shore - 01-21-2014 01:26 PM This formula calculates the day number of any date (given month and day). A 365 day year is used. If you are operating with a leap year with dates after February 28, add 1. Hence in non-leap years, January 1 is Day 1, February 1 is Day 32, etc..., December 1 is 335, and December 31 is 365. Details are at my blog: http://edspi31415.blogspot.com/2014/01/hp-prime-and-hp-32sii-day-number-of-year.html Formula: Day Number, 365 Day Year, M≤2: D + IP(30.6M + 1.6 + 367.2) - (34 + 365) = D + IP(30.6M + 368.8) - 399 M>2: D + IP(30.6M + 1.6) - 34 Here it is in RPN format. I broke up some of the larger numbers into an addition of two smaller ones and used flags to keep the program within one label. HP 32SII: Code: ``` N01 LBL N N02 CF 0 \\clear flag 0 (any user flag will do) N03 INPUT M N04 2 N05 x≥y? N06 SF 0 \\set flag 0 N07 R-down \\bring M to the X stack N08 30.6 N09 ×  N10 1.6 N11 + N12 FS? 0 N13 367.2 N14 FS? 0 N15 + N16 IP N17 INPUT D N18 + N19 34 N20 - N21 FS? 0 N22 365 N23 FS? 0 N24 - N25 CF 0 N26 RTN```