Sage 100

 View Only
Expand all | Collapse all

Error in DateDiff formula in Crystal Reports

  • 1.  Error in DateDiff formula in Crystal Reports

    Posted 03-07-2023 13:21

    I am trying to create a DaysDelinquent formula to replace the one in the AR_AgedInvoice work table. Prepayments and negative invoices do not have a value.

    the formula is DateDiff("d", AR_AgedInvoiceWork.InvoiceDueDate, @AgeingDate)

    This is a Report Setting for AR Aged Invoice Report.

    At runtime I get Error in formula ... A date is required here. Details: errorKind

    Both ...InvoiceDueDate and the formula AgeingDate are type dates from what I can tell.

    Not sure what the issue is here!?



    ------------------------------
    Greg Stiles
    S & W Microsystems
    ------------------------------


  • 2.  RE: Error in DateDiff formula in Crystal Reports

    Posted 03-07-2023 13:28

    Is this Premium?  It might be seeing one as datetime, not date. 



    ------------------------------
    Phil McIntosh
    President
    Friendly Systems, Inc.
    ------------------------------



  • 3.  RE: Error in DateDiff formula in Crystal Reports

    Posted 03-07-2023 13:29

    Check for null values and blanks.  Sage usually cleans those up for work tables, but that would depend on their programming.



    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    ------------------------------



  • 4.  RE: Error in DateDiff formula in Crystal Reports

    Posted 03-07-2023 15:06

    @Phil McIntosh I have tested it on Standard and Advanced.

    @Kevin Moyes it seems to be complaining about the formula field @AgeingDate which comes from the report screen at runtime. Definitely not blank.

    The formula works if I replace @AgeingDate with another date field, say InvoiceDate, and also works if I use #3/7/2023#



    ------------------------------
    Greg Stiles
    S & W Microsystems
    ------------------------------



  • 5.  RE: Error in DateDiff formula in Crystal Reports

    Posted 03-07-2023 15:21

    If it's a formula field, make sure you include the curly brackets.



    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    ------------------------------



  • 6.  RE: Error in DateDiff formula in Crystal Reports

    Posted 03-07-2023 15:42

    It does have the curly brackets, there are no syntax errors, the formula verifies. When I typed it above I was abbreviating for clarity.



    ------------------------------
    Greg Stiles
    S & W Microsystems
    ------------------------------



  • 7.  RE: Error in DateDiff formula in Crystal Reports

    Posted 03-07-2023 16:11

    From the report screen at runtime?  You mean a report parameter?  Make sure it is set to Date type, and not as a range, nor allowing multiple values.



    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    ------------------------------



  • 8.  RE: Error in DateDiff formula in Crystal Reports

    Posted 03-07-2023 16:13



    ------------------------------
    Greg Stiles
    S & W Microsystems
    ------------------------------



  • 9.  RE: Error in DateDiff formula in Crystal Reports

    Posted 03-07-2023 16:18

    Now that I have looked to confirm the formula, expecting it to be Formula = "", it's actually Formula = CurrentDate.

    You know what happens when you assume!

    So maybe my work around of adding a parameter for AgeingDate (they have to enter the same date as on the report screen) is the best option?



    ------------------------------
    Greg Stiles
    S & W Microsystems
    ------------------------------



  • 10.  RE: Error in DateDiff formula in Crystal Reports

    Posted 03-07-2023 16:24

    Just confirmed - the field @AgeingDate is set to whatever is entered on the report screen, despite the formula being set to CurrentDate.

     So why does it not work in the DateDiff formula?



    ------------------------------
    Greg Stiles
    S & W Microsystems
    ------------------------------



  • 11.  RE: Error in DateDiff formula in Crystal Reports

    Posted 03-07-2023 16:48

    It's probably coming in as text.  Add another formula to convert that field to a date?



    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    ------------------------------



  • 12.  RE: Error in DateDiff formula in Crystal Reports

    Posted 03-07-2023 17:39

    So this works, but why is it necessary, and what is a better method?

    create 2 additional formulas to convert aging date to text then back to a date

    @agingdate2 = totext({@ageingdate})

    @agingdate3 = cdate({@agingdate2})

    @CalculatedDaysDelinquent = DateDiff("d", {AR_AgedInvoiceWork.InvoiceDueDate}, {@agingdate3})



    ------------------------------
    Greg Stiles
    S & W Microsystems
    ------------------------------