20. august 2004 - 12:36
Der er
3 kommentarer og
1 løsning
År mellem birthday date1
Jeg har prøvet med
var
dato:Real;
birthday:TdateTime;
begin
Birthday := StrToDate('20-08-1974');
dato := Int(date)-Int(Birthday);
dato := TRUNC(dato / 365);
Label1.Caption := FloatToStr(dato);
end;
Men den tager ikke højde for skudår o.lig.
20. august 2004 - 12:43
#1
fra hjælpen
Unit
DateUtils
Category
datetime routines
Delphi syntax:
function YearsBetween(const ANow, AThen: TDateTime): Integer;
C++ syntax:
extern PACKAGE int __fastcall YearsBetween(const System::TDateTime ANow, const System::TDateTime AThen);
Description
Call YearsBetween to obtain the difference, in years, between two TDateTime values. Because years are not all the same length (e.g. leap years), YearsBetween returns an approximation based on an assumption of 365.25 days per year. Fractional years are not counted. Thus, for example, YearsBetween reports the difference between Jan 1 and Dec 31 as 0 on non-leap years and 1 on leap years.
Stoney
20. august 2004 - 12:46
#2
glemte denne
DateUtils
Category
datetime routines
Delphi syntax:
function IsInLeapYear(const AValue: TDateTime): Boolean;
C++ syntax:
extern PACKAGE bool __fastcall IsInLeapYear(const System::TDateTime AValue);
Description
Call IsInLeapYear to determine whether the year of the date specified by AValue occurs in a leap ye
Stoney