Post Reply 
Number of Days After January 1
03-11-2019, 06:53 PM (This post was last modified: 03-11-2019 07:00 PM by Dieter.)
Post: #2
RE: Number of Days After January 1
(03-11-2019 02:25 AM)Eddie W. Shore Wrote:  The program DATENO calculates the number of days from January 1.

Maybe you should add 1 to the result to get the more common "day of year", i.e. 1 January = day 1 and 31 December = day 365.

(03-11-2019 02:25 AM)Eddie W. Shore Wrote:  If M = 1 and M = 2 Then
DATE# = int(30.6 * M + 368.8) + D - 400

What about 31*M + D -32 ?-)

Anyway, here is my attempt at a day-of-year program. I have derived the formulas myself, so beware. ;-) Please try it and report any errors you find.

Code:
01 LBL "DOY"
02 4
03 MOD
04 X≠0?
05 SIGN
06 CHS
07 STO T
08 RDN
09 30,6
10 *
11 31,3
12 -
13 50
14 X>Y?
15 GTO 01
16 RDN
17 INT
18 +
19 +
20 GTO 02
21 LBL 01
22 RDN
23 1,2
24 +
25 INT
26 +
27 LBL 02
28 END

Usage:
day [ENTER] month [ENTER] year XEQ "DOY"

If you prefer month, day, year instead simply insert an X<>Y command between line 08 and 09.

The program automatically checks for leap years, this works for all dates between 1 January 1901 and 28 February 2100.

Example:
1 [ENTER] 10 [ENTER] 1999 XEQ"DOY" => 274
1 [ENTER] 10 [ENTER] 2000 XEQ"DOY" => 275

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Number of Days After January 1 - Dieter - 03-11-2019 06:53 PM



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