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

Unit
QESBPCSDateTime

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

Category
Date/Time Conversion Routines

Implementation

function OptDate2Month (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;
     if Month < 10 then
          Inc (Month, 3)
     else
          Dec (Month, 9);
     Result := Month
End;


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