DelphiBasics
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 :
1  = Sunday
2  = Monday
3  = Tuesday
4  = Wednesday
5  = Thursday
6  = Friday
7  = 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
DayOfTheMonthGives day of month index for a TDateTime value (ISO 8601)
DayOfTheWeekGives day of week index for a TDateTime value (ISO 8601)
DayOfTheYearGives the day of the year for a TDateTime value (ISO 8601)
MonthOfTheYearGives the month of the year for a TDateTime value
 Download this web site as a Windows program.




 
Example code : Show the day of the week for Christmas 2002
var
  myDate : TDateTime;
  day    : string;

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

  day := LongDayNames[DayOfWeek(myDate)];

  ShowMessage('Christmas day 2002 is on a '+day);
end;
Show full unit code
  Christmas day 2002 is on a Tuesday
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page