Skip to Content
Former Member
Dec 14, 2009 at 11:08 PM

How to create a Date Diff formulae in Crystal when domparing two different


I am trying to create a formulae that allows me to find the difference between dates in two different fields. Originalyy I was stuck being able to link an Invoice to a Purchase order. The AP invoice could have been copied from either a PO or a Goods receipt. I solved that problem by using the PCH1 file and linking it to the PDN1 file or the POR1 file based on if the Base Ref Type was a GR = 20 or a PO =22.

I have been able to link back to the DocDueDate in the PO using that method. I now want to find the difference between that and the TAX Date on the invoice? My formulae works fine when I am dealing with just one table. When I introduce the alias table I do not get the correct answer and have tried to determine how to tell the formulae to use the correct date from OPOR file if it is a GR = 20 or a PO =22.

Here is my original formula.

DateTimeVar d1 := {OPOR.DocDueDate};

Local DateTimeVar d2 := {OPCH.TaxDate};

DateDiff ("d", d1, d2)

I am not sure how to tell it when d1=20 use {OPOR.DocDueDate}; or when d1=22 use {OPOR_1.DocDueDate

Any help in this would be appreciated.