Navigation Menu Search PhysiologyWeb
PhysiologyWeb Logo Search PhysiologyWeb
   
— share —
Share on Facebook    Share on X    Share on LinkedIn    Share on Pinterest    Share on Reddit    Email    Copy URL
function LaborDay(TargetYear: Integer): TDate;
var
MondayCount: Integer;
TargetDate: TDate;
begin
LaborDay := 0;

MondayCount := 0;

TargetDate := 0;

TargetDate := StrToDate('9/1/'+IntToStr(TargetYear));
MondayCount := 0;
If DayOfTheWeek(TargetDate) = 1 then MondayCount := 1; //1 = Monday
If MondayCount = 0 then
begin
repeat
TargetDate := TargetDate + 1;
If DayOfTheWeek(TargetDate) = 1 then MondayCount := MondayCount + 1;
until MondayCount = 1;
end;

LaborDay := TargetDate;
end;

The procedure below uses the function shown above to retrieve Labor Day for a range of years. The FormatDateTime function can be used to format the date in any way desired.

procedure TForm1.Button1Click(Sender: TObject);
var
Year: Integer;
begin
For Year := 2000 to 2100 do
begin
Memo1.Lines.Add(FormatDateTime('dddd, mmmm d, yyyy', LaborDay(Year)));
end;
end;




Posted: Monday, September 4, 2023
Last updated: Tuesday, March 18, 2025
— share —
Share on Facebook    Share on X    Share on LinkedIn    Share on Pinterest    Share on Reddit    Email    Copy URL