SmartPascal
DayOfWeek
Function
Gives day of week index for a TDateTime value SysUtils unit
 function DayOfWeek ( Date : TDateTime ) : Integer;
Description
The DayOfWeek function returns an index number for the day of the week :
= Sunday
= Monday
= Tuesday
= Wednesday
= Thursday
= Friday
= Saturday
Notes
Warning : This is NOT ISO 8601 compliant.

DayOfTheWeek is ISO 8601 compliant, and uses Monday as the start of the week.
Related commands
DayOfTheMonth Gives day of month index for a TDateTime value (ISO 8601)
DayOfTheWeek Gives day of week index for a TDateTime value (ISO 8601)
DayOfTheYear Gives the day of the year for a TDateTime value (ISO 8601)
MonthOfTheYear Gives the month of the year for a TDateTime value
 
Example code : Show the day of the week for Christmas 2002
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  SysUtils,   // Unit containing the DayOfWeek command
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

var
  myDate : TDateTime;
  day    : string;

begin
  myDate := EncodeDate(2002, 12, 31);

  day := LongDayNames[DayOfWeek(myDate)];

  ShowMessage('Christmas day 2002 is on a '+day);
end;
 
end.
Hide full unit code
   Christmas day 2002 is on a Tuesday