http://www.delphibasics.co.uk/RTL.asp?Name=DayOfWeek
http://delphi.about.com/library/rtl/blrtlDayOfWeek.htm
The DayOfWeek function returns an index number for the day of the week :
http://delphi.about.com/library/rtl/blrtlDayOfWeek.htm
const Days: array[1..7] of string =
('Sunday', 'Monday', 'Tuesday',
'Wednesday', 'Thursday',
'Friday', 'Saturday')
ShowMessage('Today is ' + Days[DayOfWeek(Date)]);
//Today is Monday
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 |
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. |
Christmas day 2002 is on a Tuesday |