Did you try your code Myles? Var Y1, M1, D1 : Word; Y2, M2, D2 : Word; Age : INteger; begin DecodeDate( Date, Y1, M1, D1 ); DecodeDate( AdrockDateTimeEdit1.Date.Date, Y2, M2, D2 ); Age := (Y1 * 12 + M1) - (Y2 *12 + M2) div 12; //Do age calculation in ShowMEssage('Age = '+Inttostr(Age)); end; I got my age based on DOB of 20th December 1966, supposidly in months is 22033 months... You should change Age := (Y1 * 12 + M1) - (Y2 *12 + M2) div 12; //Do age calculation in to Age := ((Y1 * 12 + M1) - (Y2 *12 + M2)) div 12; //Do age calculation in But it is still wrong.. I am born in december, and your code without the Div 12 returns that I am 33, but infact I am only 32 until december 20th. This is quite important... I have a routine that does correctly generate a person's age in years, up to the correct Day of the month. But it is part of a larger library of 150+ date routines so I can't really paste the code here... Chris Christopher Crowe [EMAIL PROTECTED] http://www.adrock.com Want a free program to help you search the Microsoft Knowledge Base?, and other areas of Microsoft's site?, download it from http://www.adrock.com/msarticle -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Myles Penlington Sent: Thursday, 16 December 1999 17:28 To: Multiple recipients of list delphi Subject: RE: [DUG]: Date/Time calculations It is simple with the correct algorithm, otherwise can be very tricky ... Suggest you try DecodeDate( Date, Y1, M1, D1 ); DecodeDate( DOB, Y2, M2, D2 ); Age := (Y1 * 12 + M1) - (Y2 *12 + M2) div 12; //Do age calculation in months > -----Original Message----- > From: Patrick Dunford [SMTP:[EMAIL PROTECTED]] > Sent: Thursday, 16 December 1999 17:21 > To: Multiple recipients of list delphi > Subject: [DUG]: Date/Time calculations > > Has anyone else experienced problems with date/time calculations due to > Delphi offsetting the date by 30/12/1899 > > The situation is that I wish to calculate a person's current age which > appeared to be simple: subtract their date of birth from the current date > then decode into actual years. > > But Delphi insists on adding this offset to the date so I end up with a > person having an age of 1901 years. > (Delphi 3) > > Code below: > > function CurrentAge(DOB:TDateTime):integer; //Return years only > var y,m,d:word; > CDate:TDateTime; > begin > CDate:=Date-DOB; > DecodeDate(CDate,y,m,d); > Result:=y; > end; > > The date subtraction is fine and in one example produces a result of 374 > days, just over 1 year, Delphi then makes this into year 1901 but by the > calculation the actual number stored in the TDateTime is 1.0 something, > which it adds 30/12/1899 to > > The best I have come up with is to subtract 1900 from the year but this > will > be 1 day out. > > > -------------------------------------------------------------------------- > - > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] > Website: http://www.delphi.org.nz --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz
BEGIN:VCARD VERSION:2.1 N:Crowe;Chris FN:Chris Crowe ORG:Byte Computer & Software TITLE:Programmer TEL;WORK;VOICE:3651-112 TEL;HOME;VOICE:3385-392 ADR;WORK;ENCODING=QUOTED-PRINTABLE:;;132 Peterbrough Street=0D=0AChristchurch 8001;261-655;;;New Zealand LABEL;WORK;ENCODING=QUOTED-PRINTABLE:132 Peterbrough Street=0D=0AChristchurch 8001=0D=0A261-655=0D=0ANew Zealand ADR;HOME;ENCODING=QUOTED-PRINTABLE:;;59 McBeath Ave=0D=0AHoon-Hay;Christchurch;;8002;New Zealand LABEL;HOME;ENCODING=QUOTED-PRINTABLE:59 McBeath Ave=0D=0AHoon-Hay=0D=0AChristchurch 8002=0D=0ANew Zealand URL: URL:http://www.adrock.com ROLE:Delphi Programmer, Component Builder, Web Page Development, Vertical Market Applications EMAIL;PREF;INTERNET:[EMAIL PROTECTED] EMAIL;INTERNET:[EMAIL PROTECTED] EMAIL;INTERNET:[EMAIL PROTECTED] REV:19991029T010606Z END:VCARD