Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculating Years and Days
Message
 
À
21/05/2013 02:14:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01574342
Message ID:
01574344
Vues:
66
>I am looking for some command or code that could hep in getting the number of Years and Days between Two Dates.
> For example, if commence_date='31/03/2011' and Current_date is '31/03/2013', I need Y=2 and D=1.
>
>Similarly if if commence_date='20/02/2012' and Current_date is '31/03/2013', I need Y=1 and D=41 ( as 2012 was a Leap Year).
>
>Kinldy Help
CLEAR
ldDate1 = DATE(2012, 2, 20)
ldDate2 = DATE(2013, 3, 31)

lnYears = YEAR(ldDate2) - YEAR(ldDate1)
IF MONTH(ldDate2) < MONTH(ldDate1) OR;
   DAY(ldDate2)   < DAY(ldDate1)
   lnYears = lnYears - 1
ENDIF

ldDate3 = GOMONTH(ldDate1, 12 * lnYears)

lnDays  = ldDate2 - ldDate3
? "Y:", lnYears,"D:",lnDays
NOT TESTED!!!
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform