OptDate2Year Function
A Speed Optimised Routine for getting the Year portion of a Date based on Routine by Ken Otto that is many times faster than using DecodeDate in SysUtils.

Unit
QESBPCSDateTime

Declaration
Function OptDate2Year(const DT: TDateTime): Word;

Category
Date/Time Conversion Routines

Implementation

function OptDate2Year (const DT: TDateTime): Word;
var
     J: Integer;
     Day, Month, Year: Integer;
begin
     J := pred ((Trunc (DT) + 693900) shl 2);
     Year := J div 146097;
     Day := (J - 146097 * Year) shr 2;
     J := (Day shl 2 + 3) div 1461;
     Day := (Day shl 2 + 7 - 1461 * J) shr 2;
     Month := (5 * Day - 3) div 153;
     Year := 100 * Year + J;
     if Month >= 10 then
          Inc (Year);
     Result := Year
End;


HTML generated by Time2HELP
http://www.time2help.com