首页  编辑  

给出日期,如何知道是这一年的第几周?

Tags: /超级猛料/Date.Time.时间和日期/   Date Created:

]、。·ˉˇ¨〃々—~‖…’”〕〉》」』〗】∶!"'),.:;?]` function WeekofYear(Date: TDate): integer;

var

 FirstDay, FirstWeekEnd, NowWeekEnd: TDate;

 Year, Month, Day: word;

begin

 DecodeDate(Date, Year, Month, Day);

 FirstDay := EncodeDate(Year, 1, 1);

 FirstWeekEnd := FirstDay +  7 - DayofWeek(FirstDay);

 NowWeekEnd := Date + 7 - DayofWeek(Date);

 Result := Round(NowWeekEnd - FirstWeekEnd) div 7 + 1;

end;