Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculate Duration in years
Message
De
22/03/1999 12:59:40
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
22/03/1999 12:25:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00200532
Message ID:
00200562
Vues:
11
>I have the need to calculate the timespan in years between 2 dates. Getting the number of days between is no problem; figuring out how many years 1426 days is is another question. I am able to get fairly close using days/365.25 but I don't think this is going to cut it. I am aware of the financial terms 30/360 and Actual/Actual, but don't know how to use these methods to calculate duration. Anybody have a clue?
Erik,
I don't know financial rules but this could help :
lparameters tdBirth
ldCalcDate = tdBirth
lnMonths = 0
do while gomonth( ldCalcDate, 1 ) <= date()
  ldCalcDate = gomonth( ldCalcDate, 1 )  
  lnMonths = lnMonths + 1
enddo
lnYears = int( lnMonths / 12 )
lnMonths = lnMonths - ( lnYears * 12 )
lnDays   = date() - ldCalcDate
? lnYears, lnMonths, lnDays
I like this one for it takes leap years into account as appropriate.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform