uses Windows, Messages, Classes, SysUtils, DateUtils;
//下面的函数可以得到第几周的星期一和星期天的datetime值,
//输入年nYear, 周数nWeekNO, 输出 星期一是那一天,星期天是那一天
//你改一下就可以得到你要的东本
procedure GetMyWeekDays(nYear, nWeekNo: integer;
var dtMonday, dtSunday: TDatetime);
var
i ,j : integer;
nInitDays : integer;
//今天是今年的第几天
nSurplusDays : integer;
nDaysInThismonth : integer;
begin
nInitDays :=(nWeekNo-1)*7+2-DayOftheWeek(StrToDatetime(IntToStr(nYear)+'-01-01'));
nSurplusDays :=nInitDays;
for i :=1 to 12do
begin
nDaysInThismonth := DaysInMonth(StrToDatetime(IntToStr(nYear)+'-'+IntToStr(i)+'-01'));
if nSurplusDays > nDaysInThismonth then
nSurplusDays:=nSurplusDays - nDaysInThismonth
else
break;
end;
if nWeekNo>1 then
//如果不是第一周
dtMOnday := StrToDatetime(IntToStr(nYear)+'-'+IntToStr(i)+'-'+IntToStr(nSurplusDays))
else
//如果是第一周
dtMOnday := StrToDatetime(IntToStr(nYear)+'-01-01');
// showmessage('第'+intToStr(nNo)+'周的星期一是' + DatetimeToStr(dtMOnday));
nSurplusDays :=nInitDays+6;
for j :=1 to 12do
begin
nDaysInThismonth := DaysInMonth(StrToDatetime(IntToStr(nYear)+'-'+IntToStr(j)+'-01'));
if nSurplusDays > nDaysInThismonth then
nSurplusDays:=nSurplusDays - DaysInMonth(StrToDatetime(IntToStr(nYear)+'-'+IntToStr(j)+'-01'))
else
break;
end;
dtSunday := StrToDatetime(IntToStr(nYear)+'-'+IntToStr(j)+'-'+IntToStr(nSurplusDays));
// showmessage('第'+intToStr(nNo)+'周的星期天是' + IntToStr(nYear)+'年'+IntToStr(j)+'月'+IntToStr(nSurplusDays)+'日');
end;