Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculate the age
Message
De
14/09/2004 12:41:36
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00941958
Message ID:
00941961
Vues:
52
This message has been marked as the solution to the initial question of the thread.
>Dear All
>How i can calculate the Aage in days, months and year
> someone born on:12/08/1980(brit Date) if i subtract this age in today date. I find resutl.
>Days: 02
>Month:01
>years:24
>How i can find with some coding
>thanks
oAge = createobject('Age')
ldBirth = {^1961/1/19}
ldTarget = date() && How old is he today.
oAge.CalcAge(ldBirth, ldTarget)
? oAge.Years, oAge.Months, oAge.Days

Define Class age As Relation
  Years=0
  Months=0
  Days=0
  Procedure CalcAge
  Lparameters tdBirth, tdTarget
  Local ldTemp, ldBirth, lnDrop
  If tdBirth > tdTarget
    ldTemp = tdTarget
    tdTarget = tdBirth
    tdBirth = ldTemp
  ENDIF
  ldBirth = Date(Year(tdTarget),Month(tdBirth),Day(tdBirth))
  lnDrop = 0
  If Empty(ldBirth) && leap case
    ldBirth = Date(Year(tdTarget),3,1)
    lnDrop = IIF(MONTH(tdTarget)<=2,0,1)
  ENDIF
  With This
    .Years = Year(tdTarget) - Year(tdBirth) - (Iif(ldBirth > tdTarget,1,0))
    .Months = (Month(tdTarget) - Month(tdBirth) + 12 - ;
    	(Iif(Day(tdBirth)>Day(tdTarget),1,0)))%12
    .Days = tdTarget - Gomonth(tdBirth,.Years*12+.Months) - lnDrop
  Endwith
Endproc
Enddefine
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