怎样判断星期六、星期天(100分)

F

fxingf

Unregistered / Unconfirmed
GUEST, unregistred user!
[:(]在我选择一个日期后怎样判断是不是星期六、星期天
 
if DayOfWeek(Date) in [7, 1] then { TODO : 周六、周日};
 
const

DayMonday = 1;
DayTuesday = 2;
DayWednesday = 3;
DayThursday = 4;
DayFriday = 5;
DaySaturday = 6;
DaySunday = 7;
应该6和7吧
 
var
ADate: TDateTime;
days: array[1..7] of string;
begin
days[1] := 'Sunday';
days[2] := 'Monday';
days[3] := 'Tuesday';
days[4] := 'Wednesday';
days[5] := 'Thursday';
days[6] := 'Friday';
days[7] := 'Saturday';
ADate := StrToDate(Edit1.Text);
ShowMessage(Edit1.Text + ' is a ' + days[DayOfWeek(ADate)];
end;
 
function DayOfTheWeek(const AValue: TDateTime): Word;

Description

Call DayOfTheWeek to obtain the day of the week represented by a specified TDateTime value. DayOfTheWeek returns a value between 1 and 7, where 1 indicates Monday and 7 indicates Sunday.

Note: DayOfTheWeek is ISO 8601 compliant (where Monday is considered the first day of the week). To obtain the day of the week where Sunday is considered the first day of the week, use the DayOfWeek function instead.
Tip: To make the return value more readable, use the Day of week constants.
 
多人接受答案了。
 
顶部