It's not at all a dumb question. Here's an algorithm in Delphi which claims to do what you require. It should be a simple exercise to convert it to Progress.
Please post it if you do.
http://www.delphipages.com/threads/thread.cfm?ID=70191&G=70167
Be aware there are locale issues involved, and assumptions about how a week fits in a month, but it should provide you with a starting point.
----
Quote:
As promised here comes my adaption of the ISO8601 week of month algorithm:
function MyWeekOfMonth(date:TDateTime):integer;
var
y,m,d: word;
firstofmonth,
firstthursday,
FirstWeekStart: TDateTime;
h: integer;
begin
decodedate(date,y,m,d);
FirstOfMonth:=encodedate(y,m,1);
h:=dayOfWeek(FirstofMonth);
FirstThursday:=FirstofMonth+((12-h) mod 7);
FirstWeekStart:=FirstThursday-3;
if trunc(date)<FirstWeekStart then
result:=MyWeekofMonth(FirstofMonth-1) (* last day of previous month *)
else
result:=(round(trunc(date)-FirstWeekStart) div 7)+1;
if m=12 then begin
inc(y);
m:=0;
end;
(* check if the day is already in the first week of the next month *)
FirstOfMonth:=encodedate(y,m+1,1);
h:=dayOfWeek(FirstofMonth);
FirstThursday:=FirstofMonth+((12-h) mod 7);
FirstWeekStart:=FirstThursday-3;
if FirstWeekStart<=date then
result:=MyWeekofMonth(FirstThursday);
end;
Notice that the first days of a month can belong to the last week of the previous month, or the last days of a month can belong to first week of the next month. In these cases the above algorithm will return that number. If you just want to count the week in the month by setting the 1st to week 1 the algorithm will be much easier:
function MyWeekOfMonth(date:TDateTime):integer;
var
y,m,d: word;
firstofmonth,
firstthursday,
FirstWeekStart: TDateTime;
h: integer;
begin
decodedate(date,y,m,d);
FirstOfMonth:=encodedate(y,m,1);
h:=dayOfWeek(FirstofMonth);
FirstThursday:=FirstofMonth+((12-h) mod 7);
FirstWeekStart:=FirstThursday-3;
if FirstWeekStart<date then
result:=(round(trunc(date)-FirstWeekStart) div 7)+2
else
result:=1;
end;
------
HTH
Lee