Post Reply 
How many Years Months and Days ?
03-10-2015, 10:07 PM (This post was last modified: 03-10-2015 10:13 PM by Dieter.)
Post: #4
RE: How many Years Months and Days ?
(03-08-2015 06:57 PM)ggauny@live.fr Wrote:  Very possible to enhance the output and port on any machine.

You said you also want to try the 34s, so here is a first idea on how to do it using the built-in date functions.
Caution: this code is completely untested, I finished it just five minutes ago. Any error you can imagine is possible. ;-)

Code:
LBL'YMD'
STO 02
DAY
x<>y
STO 01
DAY
x≤y?
GTO 01
#012
RCL 02
YEAR
RCL 02
MONTH
DEC X
x=0?
DEC Y
x=0?
x<>Z
RCL T
GTO 02
LBL 01
RCL 02
YEAR
RCL 02
MONTH
RCL Z
LBL 02
→DATE
RCL 01
RCL Y
ΔDAYS
#012
x
#a
/
ROUNDI
RCL X
#012
IDIV
x<>Y
#012
RMDR
RCL Z
RCL 02
ΔDAYS
RTN

Enter date1 [ENTER] date2 using the currently set date format, where date1 is the earlier date resp. date2 the later one. The number of years, months and days is returned on the stack (Z, Y and X).

Example (assuming d.my mode):
Code:
  14,071979 [ENTER] 4,052011

     XEQ'YMD'

     Z = 31
=>   Y =  9
     X = 20

i.e. 31 years, 9 months and 20 days.

If you prefer the result in one single value, simply add these lines before the final RTN:

Code:
SDR 002
+
SDR 002
+
FIX 04

This way the example would return 31,0920.

As usual, comments and corrections are welcome.

Dieter

Edit: Sorry, I just realized this is the 41C software library. ;-)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: How many Years Months and Days ? - Dieter - 03-10-2015 10:07 PM



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