0

I have no problem generating a report from a MySQL query or table. The problem starts when I want to add a variable in the report in each row.

For example, table "PRODUCTS": ID|PRODUCT-NAME|SHELF-LIFE

What's the best practice if I want to generate a report that shows me

ID | NAME | EXPIRE-DAY

Where: EXPIRE-DAY = TODAY + SHELF-LIFE

Thanks in advance for your help, even a link would be greatly appreciate.

ifconfig
  • 6,242
  • 7
  • 41
  • 65

2 Answers2

0

You may use FR's internal function DATE to get current date: [Date + <YourDatasetName."SHELF-LIFE">]

gpi
  • 486
  • 4
  • 8
  • `DATE` is not a function but a [system variable](https://www.fast-report.com/documentation/UserManFrNET-en/index.html?usesystemvariablesinexpressions.htm). – Victoria Jun 14 '17 at 05:35
  • Date is function too. See Functions tab in the Data Tree or use such script `begin ShowMessage(Date); ShowMessage(); end.` – gpi Jun 14 '17 at 10:05
  • Not in term of expressions, which is what you've shown. Besides, I guess those two notations would return different values, `` one refers to that system variable (the same you used in the expression in your answer) whilst `Date` is a function exported by PascalScript and returns the same as Delphi, that is, a value of current date with time portion set to 0 which differs from a date time value returned by that variable. P.S. such script would fail. – Victoria Jun 14 '17 at 10:20
  • Such script `procedure ReportTitle1OnBeforePrint(Sender: TfrxComponent); begin ShowMessage(Date); ShowMessage(); ShowMessage(Now); ShowMessage(Time); ShowMessage( – gpi Jun 14 '17 at 11:13
  • Sorry, then they must have add overloads for `ShowMessage` procedure, because the one exported from PascalScript accepts only string parameters. From what you say it accepts also `TDateTime` parameters. Good to know. Thanks! – Victoria Jun 14 '17 at 11:38
0

Three Options:

  1. Use FR-functions to add your days.
  2. Use a variable in FR and calculate in Delphi via .OnGetValue-event
  3. Add the calculation of EXPIRE-DAY to your MySQL-Query

something like:

Select ID, NAME, SHELF-LIFE, DATE_ADD( CURDATE(), INTERVAL SHELF-LIFE DAY) as EXPIRE-DAY from mytable
Daniel
  • 426
  • 3
  • 14