This formula will do what you want.
@Thursday
global datevar first;
global datevar last;
global datevar start:=currentdate;
//global datevar start:=date(2010,6,20);
if day(start) > 7 then
first:= Date(year(dateadd("m", 1, start)), month(dateadd("m", 1, start)), 01)
else
first:= Date(year(start), month(start), 01);
last:= Date(year(dateadd("m", 1, start)), month(dateadd("m", 1, start)), 01)-1;
if currentdate > last - 7 then first - weekday(first) + 5
else
If first < start and start < first-weekday(first) + 19 then first-weekday(first) + 19 else
first-weekday(first) + 5;
You can test it by commenting out where Start = current date and use the manual setting for Start.
Ian