Post Reply 
Number of Days After January 1
03-11-2019, 02:25 AM
Post: #1
Number of Days After January 1
Introduction

The program DATENO calculates the number of days from January 1. The program prompts whether we are working in a leap year or not.

With D = Day and M = Month, the days between January 1 and any other date within the calendar year is:

If M = 1 and M = 2 Then
DATE# = int(30.6 * M + 368.8) + D - 400

Otherwise,
DATE# = int(30.6 * M + 1.6) +D - 35 (non-leap year)
DATE# = int(30.6 * M + 1.6) + D - 34 (leap year)

HP 41C/DM 41L Program: DATENO

(^T: beginning of an alpha string)

Code:
01 LBL^T DATENO
02 ^T MONTH
03 PROMPT
04 STO 01
05 ^T DAY?
06 PROMPT
07 STO 02
08 ^T LEAP? N=0,L=1
09 PROMPT
10 STO 03
11 RCL 01
12 3
13 X<=Y?
14 GTO 00
15 30.6
16 RCL 01
17 *
18 368.8
19 +
20 INT
21 RCL 02
22 +
23 400
24 -
25 GTO 01
26 LBL 00
27 RCL 01
28 30.6
29 *
30 1.6
31 +
32 INT
33 RCL 02
34 + 
35 35
36 - 
37 RCL 03
38 + 
39 LBL 01
40 STO 04
41 END

Examples

Days between January 1 and February 16 (M = 2, D = 16): 46

Days between January 1 and October 1 (M = 10, D = 1):
(Non-leap year): 273
(Leap year): 274

Link to blog post: https://edspi31415.blogspot.com/2019/03/...-days.html
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Number of Days After January 1 - Eddie W. Shore - 03-11-2019 02:25 AM



User(s) browsing this thread: 1 Guest(s)