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!

calculating dates when suppressing records 1

Status
Not open for further replies.

timISST

MIS
Jun 12, 2012
35
US
Making a report that I have set up group by client then dates are sorted decending and I have the section suppress if the count is greater than 3 so I get the last 3 records. that works fine. My issue is I need to be able to calculate ( todays date - the newest records date), the newest records date - the next newest record or format the date to change to red if it is past x number of days
 
Create a formula like this:

//{@Gap}
If onfirstrecord or
{table.client}<> previous({table.client}) then
Currentdate-{table.date} else
{table.date}-previous({table.date})

Then select {table.date}->right click->format field->borders->background->color->x+2 and enter:

If {@Gap} > {?NoOfDays} then crRed else
CrNoColor //use a number parameter {?NoOfDays} or replace it with a hard value number, e.g., 5.

This assumes you are testing for lengths of time between records. This would turn the earlier of the two records red in each case.

-LB
 
so to make sure I'm understanding you right ( and thank you) theres no way to do the cr formatting on each one separately? ie the number of days between the 1st and second date isn't > the no of days?
 
I'm not following. Did you try this? What results did you get, and how did the results differ from the desired result?

-LB
 
What I meant to say was the crred control cannt be applied separately to the 2 results?
 
The CRRed would be applied based on the results on the formula that LInda provided.
 
What two results? Please answer my earlier questions so I can understand the issue.

-LB
 
Ok it works awesome thank you for that the only issue I have and here is my formula is the second date comes out as a negative number can you tell why?
If onfirstrecord or
({Name})<> previous({Name}) then
Currentdate-{data.Data_Entry_Date} else
{data.Data_Entry_Date}-previous({data.Data_Entry_Date})
 
Sorry--the last line should be:

previous({table.date})-{table.date}

-LB
 
awesome thank you!! now I was thrown a curve which I hope can be corrected easily with this is there a way to do a count on the records so they can see how many were done "on first record" and the previous record?
 
Do you mean you need the number of instances where the difference exceeds a certain value? Do you need the result as a summary per client group? Or only for the report as a whole?

-LB
 
Create a formula {@cntgap} to be placed in the detail section:

Whileprintingrecords;
Numbervar cnt;
Numbervar gapcnt;

If onfirstrecord or
{table.client}<> previous({@table.client}) then
Cnt := 1 else
Cnt := cnt + 1;

If cnt in 1 to 3 and
{@gap} > {?NoOfDays} then
Gapcnt := gapcnt + 1;

You can suppress this formula if you like.

Then create a formula {@gapcntresult} like this for the report footer:

Whileprintingrecords;
Numbervar gapcnt;

I didn't test this, but think it should work.

-LB


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top