Skip to Content
author's profile photo Former Member
Former Member

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.



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Dec 15, 2009 at 05:36 AM

    Sample query

    SELECT T0.[DocDueDate],t1.taxdate,DATEDIFF ( dd , T0.[DocDueDate], t1.taxdate )as 'Date Diff' 

    For your reference

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.