HP Forums
Y M D between dates. - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP Prime Software Library (/forum-15.html)
+--- Thread: Y M D between dates. (/thread-2840.html)



Y M D between dates. - ggauny@live.fr - 01-12-2015 12:05 PM

Hi,
I sometime need to know Y M D between dates, so i use this codes :

  1 D A M J ~ E X P O R T D A M J ( D T 1 , D T 2 )
B E G I N
L O C A L a , b , c , d , e , f , g , h ;
L O C A L i , j , L ;
a : = I P ( D T 1 ) ; b : = I P ( F P ( D T 1 ) * 1 0 0 ) ;
c : = I P ( F P ( F P ( D T 1 ) * 1 0 0 ) * 1 0 0 0 0 ) ;
d : = I P ( D T 2 ) ; e : = I P ( F P ( D T 2 ) * 1 0 0 ) ;
f : = I P ( F P ( F P ( D T 2 ) * 1 0 0 ) * 1 0 0 0 0 ) ;
{ 3 1 , 2 8 , 3 1 , 3 0 , 3 1 , 3 0 , 3 1 , 3 1 , 3 0 , 3 1 , 3 0 , 3 1 } ¶%L ;
g : = d - a ; h : = 0 ;
I F ( i r e m ( c , 4 ) = = 0 A N D i r e m ( c , 1 0 0 ) `"0 ) O R
i r e m ( c , 4 0 0 ) = = 0
T H E N 2 9 ¶%L [ 2 ]
E N D ;
I F g < 0
T H E N 1 ¶%h ; g + L [ b ] ¶%g ;
E N D ;
e - b - h ¶%i ; 0 ¶%h ;
I F i < 0
T H E N 1 ¶%h ; i + 1 2 ¶%i ;
E N D ;
f - c - h ¶%j ;
P R I N T ( j + " a n ( s ) " + i + " m o i s " + g + " j o u r ( s ) " ) ;
E N D ;
[/code]

For exemple : i am borned the 21 02 1935 so i am alive for :

21.021935...12.012015 hence : 79 ans 10 mois and 19 jours.
It is more speaking then delta days=29180 days no ?
For all have a good day.
Gérard.