GetFirstDayOfMonth Routines
Returns First Day of the Month, for a given Date/Time - Time portion preserved.

Unit
QESBPCSDateTime

Overloaded Variants
Function GetFirstDayOfMonth(const DT: TDateTime): TDateTime;
Function GetFirstDayOfMonth(const Month, Year: Word): TDateTime;
Function GetFirstDayOfMonth(const Month, Year: Integer): TDateTime;

Declaration
Function GetFirstDayOfMonth(const DT: TDateTime): TDateTime;

Description
Alternatively for a given Month Year.

Parameters
DT Date/Time to process.
Month Month in given year, 1 = Jan, 12 = Dec.
Year 4-digit Year, such as 1999.

Category
Date/Time Arithmetic Routines
Month Based Arithmetic Routines

Implementation

function GetFirstDayofMonth (const DT: TDateTime): TDateTime;
var
     D, M, Y: Integer;
begin
     OptDecodeDateI (DT, Y, M, D);
     Result := OptEncodeDateI (Y, M, 1) + Frac (DT);
End;

Declaration
Function GetFirstDayOfMonth(const Month, Year: Word): TDateTime;

Implementation

function GetFirstDayofMonth (const Month, Year: Word): TDateTime;
begin
     Result := OptEncodeDateW (Year, Month, 1);
End;

Declaration
Function GetFirstDayOfMonth(const Month, Year: Integer): TDateTime;

Implementation

function GetFirstDayofMonth (const Month, Year: Integer): TDateTime;
begin
     Result := OptEncodeDateI (Year, Month, 1);
End;


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