use...... DateUtils
function StartOfTheMonth(const A Value: TDateTime):TDateTime;該月起始日期
function EndOfTheMonth(const A Value: TDateTime):TDateTime;該月結束日期
function DaysInMonth(const A Value: TDateTime):word;該月有幾天
配合 function DayOfWeek(const A Value: TDateTime):word;
寫個迴圈就可計算出來了
例如要計算以今天為準當月有幾天不含六、日
var i,j :integer;
mydate :TDateTime;
.
.
j:=0;
mydate:=StartOfTheMonth(date());
for i:=1 to DaysInMonth(date()) do begin
if (DayOfWeek(mydate)<>1)and(DayOfWeek(mydate)<>7) then begin
j:=j+1;
end;
mydate:=mydate+1;
end;
沒有留言:
張貼留言