strfmt range in x++

what’s wrong with this range?

    rangeTransDate = strFmt('(("%1.%2" <= "%3" && "%3" == "%5") || ("%1.%4" > "%3"))',tableStr(CustomTable),fieldStr(CustomTable,TransDate), date2str(dateTo,321,2,0,2,0,4),fieldStr(CustomTable,SettlementDate),SysQuery::valueEmptyString());

i’m getting this error:

Query extended range error: Right parenthesis expected next to position 72.

I see many potential bugs in this single line of code. You should start with something simple, test it and gradually add more logic. You didn’t do that and now you have no idea what’s going on, therefore your approach clearly doesn’t work for you.

Here is a list of problems I see there:

  1. You should use parenthesis around each expression.
  2. Don’t quotations makes around anything that isn’t a string literal. Now you don’t ever refer any fields, because SQL code will contain things like “CustomTable.TransDate” instead of CustomTable.TransDate.
  3. tableStr(CustomTable) may work in some cases, but not in others. The right value is the name of the CustomTable data source (QueryBuildDataSource.name()).
  4. Your conversion of the date to string isn’t correct. Use date2StrXpp() instead.
  5. The comparison of %3 (a date) and %5 (the empty string) makes no sense.
  6. I’m not sure that SysQuery::valueEmptyString() is the right method here. Make sure you test it.