[Lazarus] DateDif function needed
waldo kitty
wkitty42 at windstream.net
Thu Nov 14 14:52:15 CET 2013
On 11/14/2013 7:25 AM, José Mejuto wrote:
> Maybe I'm completly wrong ?
you are completely right, IMHO... one simply needs to choose their desired base
and level of error that is acceptable for their task's needs...
the initial problem arose because there's no easy way to calc the desired output
with the existing routines and a lot of dancing about... spreadsheets and other
languages are in the same boat, too, with the routines they offer...
eg: openOffice Calc - no easy way to retain only the fraction of a result so one
must dance with subtracting and truncating all the while recalculating the
values over and over again... one can elect to use some scratchpad area on the
sheet to store some intermittent values...
witness: these formulas from Calc using fractional estimations like existing
routines in FPc/Lazarus
[without scratchpad]
total days: =DAYS(A2;B2)
whole years: =INT(C2/365.25) [C2 holds total days value]
whole months: =INT((((C2/365.25)-TRUNC(C2/365.25))*365.25)/30.4375)
whole days:
=ROUND((((((C2/365.25)-TRUNC(C2/365.25))*365.25)/30.4375)-TRUNC(((((C2/365.25)-TRUNC(C2/365.25))*365.25)/30.4375)))*30.4375)
[with scratchpad]
end date: 08/01/2018 [MM/DD/YYYY in A2]
start date: 11/14/2013 [MM/DD/YYYY in B2]
days between: =DAYS(A2;B2) [in C2] 1721
real years: =C2/365.25 [in AD2] 4.7118412047
int years: =INT(AD2) [in D3] 4
real months: =((AD2-TRUNC(AD2))*365.25)/30.4375 [in AE2] 8.5420944559
int months: =INT(AE2) [in E2] 8
real days: =((AE2)-TRUNC(AE2))*30.4375 [in AF2] 16.5
int days: =ROUND(AF2) [in F2] 17
--
NOTE: No off-list assistance is given without prior approval.
Please keep mailing list traffic on the list unless
private contact is specifically requested and granted.
More information about the Lazarus
mailing list