Sunday, March 10, 2019

TI-84 Plus and HP 41C: Number of Days After January 1

TI-84 Plus and HP 41C:  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)

TI-84 Plus Program: DATENO

"DAYS AFTER JANUARY 1"
"2019-03-07 EWS"
Input "MONTH: ",M
Input "DAY: ",D
Disp "0:NO, 1:YES"
Input "LEAP YEAR? ",L
If M≥3
Then
int(30.6*M+1.6)+D-35+L→T
Else
int(30.6*M+368.8)+D-400→T
End
Disp T

HP 41C/DM 41L Program:  DATENO

(^T:  beginning of an alpha string)

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

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation

  Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation The HP 16C’s #B Function The #B function is the HP 16C’s number of...