Min and max dates

Hi

I would like to include in the report header the date range covered by the report. e.g. sales report from oldest_date to newest_date. I can obtain the min and max dates from the report data (using sql Min(date-field) and Max(date-field) ), but then I would have to pass this data back to the report - this may be the best way if it avoids any need to do a 2 pass report.

However I see in the aggregate functions there is a min and max function. I tried these with "[min(<frxDBDataset2."Date">,MasterData1,0)]" and could get the values to appear in the footer, of course on every footer. Can I use these FR min/max functions to set the values for use as printed data in the report header, my attempts have not worked. [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> The min/max (on the page footer) works ok with a single pass report will I need to use 2 pass to set the values to print in the report header? Thank you...[/img]
Kind regards

Peter >

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 9:20PM
    Pete aggregates aren't available until the footer to put them in the header you must be 2 pass.
  • Hi
    gordk wrote: »
    Pete aggregates aren't available until the footer to put them in the header you must be 2 pass.

    Thank you for the info. I do have a footer and the min / max values appear there but using the same "[min(<frxDBDataset2."Date">,MasterData1,0)]" in a memo in either the Report Title, group header or even a page header (sorry I said report header in my original post) does not display the min/max values.

    Perhaps it's better if I pass the sql obtained values to the report, I can then avoid the 2 pass for just this option.

  • gordkgordk St.Catherines On. Canada.
    edited 9:20PM
    you miss understood what i was trying to explain
    you can't use it the way you are trying to
    once you have the value in the first pass you must store it and use it in the header in the second pass.
    look at how it is done in the main demo report under dialogs and script, totals in header
    And your way to avoid having to use 2 pass.
  • Hi Gord

    Thanks, I ended up with this...

    var
    Months: array[1..12] of string;
    Days: array[1..7] of string;
    MinDate:string;
    MaxDate:string;

    procedure ReportSummary1OnBeforePrint(Sender: TfrxComponent);
    begin
    MinDate := VarToStr(MIN(<frxDBDataset2."Date">,MasterData1,0));
    MaxDate := VarToStr(MAX(<frxDBDataset2."Date">,MasterData1,0));
    end;

    procedure ReportTitle1OnBeforePrint(Sender: TfrxComponent);
    begin
    if Engine.FinalPass then
    begin
    Memo2.Text := MinDate;
    Memo7.Text := '- ' + MaxDate;
    end
    end;


    Seems to work ok, do you see anything that needs changing/adding?
    gordk wrote: »
    And your way to avoid having to use 2 pass.

    Sorry, I don't understand your last statement about avoiding 2 pass.

    Kind regards

    Peter


Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.