Get day of week using date

Posted in DateTime

You may use DayOfWeek function. DayOfWeek returns the day of the week for a specified date..

procedure TForm1.Button1Click(Sender: TObject);
var
  MyDate: TDateTime;
begin
  MyDate:=StrToDateTime(Edit1.Text);
  case DayOfWeek(MyDate) of
    1: Label2.Caption:='Sanday';
    2: Label2.Caption:='Monday';
    3: Label2.Caption:='Tuesday';
    4: Label2.Caption:='Wednesday';
    5: Label2.Caption:='Thursday';
    6: Label2.Caption:='Friday';
    7: Label2.Caption:='Saturday';
  end;
end;