1. Home
  2. Computing & Technology
  3. Delphi Programming
Glossary|Tips/Tricks|FREE App/VCL|Essentials|Books|Link Back

Delphi Programming RTL Reference|By Category|Alphabetically|By Unit
 

YearsBetween

unit
DateUtils
category
date/time routines

declaration
function YearsBetween(const SomeDate, AnotherDate: TDateTime): Integer;

description
Gives the number of whole years between two specified dates.

YearsBetween returns an approximation based on an assumption of 365.25 days per year.

example
var dtSome, dtAnother : TDateTime;
    DaysFromBirth : integer;

dtSome := EncodeDate(2003, 1, 1);
dtAnother := EncodeDate(2003, 12, 31);

YearsBetween(dtSome, dtAnother) == 1 //non-leap year

dtSome := EncodeDate(2000, 1, 1);
dtAnother := EncodeDate(2000, 12, 31);

YearsBetween(dtSome, dtAnother) == 0 // leap year

in real code

see also
TDateTime, YearSpan, WithinPastYears


 Free Delphi code snippet inside every Delphi Newsletter!
Subscribe to the Newsletter
Name
Email

 Got some code to share? Got a question? Need some help?
Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2009 About.com, a part of The New York Times Company.

All rights reserved.