| GetFirstDayOfQuarter Routines | 
Unit
QESBPCSDateTime
| Overloaded Variants | 
Declaration
Function GetFirstDayOfQuarter(const DT: TDateTime): TDateTime;
| Parameters | 
| DT | Date/Time to process. | 
| Qtr | Quarter No, 1 through 4. | 
| Year | 4-digit Year such as 1999. | 
Category
Date/Time Arithmetic RoutinesImplementation
 
| function GetFirstDayofQuarter (const DT: TDateTime): TDateTime;
var
     D, M, Y: Integer;
begin
     OptDecodeDateI (DT, Y, M, D);
     case M of
          1..3: M := 1;
          4..6: M := 4;
          7..9: M := 7;
          10..12: M := 10;
     end;
     Result := OptEncodeDateI (Y, M, 1) + Frac (DT);
End; | 
Declaration
Function GetFirstDayOfQuarter(const Qtr: Byte; const Year: Word): TDateTime;Implementation
 
| function GetFirstDayofQuarter (const Qtr: Byte; const Year: Word): TDateTime;
begin
     Result := OptEncodeDateW (Year, (Qtr - 1) * 3 + 1, 1);
End; | 
Declaration
Function GetFirstDayOfQuarter(const Qtr, Year: Integer): TDateTime;Implementation
 
| function GetFirstDayofQuarter (const Qtr, Year: Integer): TDateTime;
begin
     Result := OptEncodeDateI (Year, (Qtr - 1) * 3 + 1, 1);
End; | 
|  |