Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saturdays

Status
Not open for further replies.

sopomeres

MIS
Jan 16, 2003
61
US
In CR8.5, how in a formula can I identify or list all Saturdays in a year?

Thank you.
Los
 
First create a number parameter for year, and then create three formulas:

//{@datecalc}:
whileprintingrecords;
datevar sats := Date({?year},01,01) - dayofweek(Date({?year},01,01)) + 7;
datevar sats2 := Date({?year},01,01) - dayofweek(Date({?year},01,01)) + 7 + (7*26);
numbervar counter;
stringvar results;
stringvar results2;

for counter := 0 to 25 do(
datevar x := sats + 7*counter;
if instr(results, totext(x,"MM/dd/yy")) = 0 then
results := results + totext(x,"MM/dd/yy") + chr(13));
for counter := 0 to (if dayofweek(Date({?year},01,01)) = 7 then 26 else
25) do(
datevar x := sats2 + 7*counter;
if instr(results2, totext(x,"MM/dd/yy")) = 0 then
results2 := results2 + totext(x,"MM/dd/yy") + chr(13));

//{@display1}:
whileprintingrecords;
stringvar results;

//{@display2}:
stringvar results2;

Insert a text box, and add {@display1} and {@display2} to the text box. This way you won't run into the 254-character limit.

-LB
 
This provided me with Saturdays for the first half of the year only. I will check to see if there are filters or suppressions set up. Thank you.

How can I identify every Saturday prior to '1/2/1999' going back 10 years?


 
I tested these formulas and copied them directly into the post, so I know that they work and provide Saturdays for the entire year.

You can use this formula for any year, but as you can see it results in dates that appear in a text box in one record. Before going too much further, I think you should explain what you want to use these dates for--if for anything other than display. For the past 10 years, you could modify the formulas, making each variable a local variable, and then copy it and create new formulas, changing {?year} to {?year}-1, {?year}-2 etc. Create new display formulas to match these, and place these in the text box.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top