Skip to Content

Crystal Report SUM Case when

Good Day Expert,

How can I apply this code in Crystal report? Bec im always got an error "DateDiff is out of range"

ISNULL(SUM(CASE when (DATEDIFF(dd,JDT1.RefDate,@Date) <=0)
then
case when syscred <> 0 then syscred * - 1
else sysdeb
end
end),0.00)

or

SELECT datediff("dd",{JDT1.RefDate},{?FromDate})
Case is >0: Sum({JDT1.BalDueDeb})-sum({JDT1.BalDueCred})
Default: 0

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Feb 16, 2017 at 08:44 AM

    Hi Romel,

    "dd" is not a valid interval type; it is "d".

    If datediff("d",{JDT1.RefDate},{?FromDate}) > 0 then

    Sum({JDT1.BalDueDeb})-sum({JDT1.BalDueCred})

    else 0

    -Abhilash

    Add comment
    10|10000 characters needed characters exceeded

    • Thank you so much sir.

      Can you help me to my report. I want to display sum of previous balance when my parameter is JDT1RefDate>=FromDate and JDT1.RefDate<=ToDate. I want to display the Sum(BalDuedeb-BaldueCred) when JDT1.RefDate<FromDate

      Thanks