Skip to Content
avatar image
Former Member

"Date is required here" exception is thrown for SQLExpression in RecordSelection formula

Hi,

We have added SQL expression named "Today1" using RAS (reportclientdocument). SQLExpression returns current date.

Crystalrreport Engine is not able to recognize SQL expression "Today1" as Date data type.

Following condition is added to ReportSelectinFormula boReportDocument.DataDefinition.RecordSelectionFormula = "Date(2016, 11, 30) = {%Today}";

When we run report, it throws following exception.

"Date is required here"

exception is thrown for SQLExpression in RecordSelectionformula

Code Snippet boReportClientDocument.DataDefController.FormulaFieldController.AddByName("Today1", "SYSDATE", CrFormulaSyntaxEnum.crFormulaSyntaxSQL);

string error = boReportClientDocument.DataDefController.FormulaFieldController.Check(formulaField);

boReportDocument.DataDefinition.RecordSelectionFormula = "Date(2016, 11, 22) = {%Today1}";

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Nov 30, 2016 at 05:21 PM

    Hi Sandeep,

    I'm wondering if the SQLExpression is returning a DateTime instead of Date. Try using CDate around it like:

    boReportDocument.DataDefinition.RecordSelectionFormula = "Date(2016, 11, 22) = CDate ({%Today1})";

    Brian

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Brian for the response, however data type is date itself. I face same problem even for Numeric data types. SQLExpression is created by default with String data type and does not anticipate that its contents are returning date field.