vendredi 27 novembre 2015

Crystal Reports Else If statement

I can't figure out why this if statement won't work. I have a DateTime field DATEFROM and a String parameter (it HAS to be String) periodEnd. I would like to calculate percentages depending if these two dates have 1, 2, 3 or more years difference. When I use this formula I get either "100%" or "-" and never the other two options. It's like CR calculates the first IF and if it's true then: "100%" but if it's false, it never checks for the rest of the Else Ifs and goes dirreclty to Else

StringVar percentage:="";
If (cDate({?periodEnd})-{TABLE.DATEFROM})<=1 Then 
    percentage:="100%"
Else If (cDate({?periodEnd})-{TABLE.DATEFROM})<=2 Then 
    percentage:="66%"
Else If (cDate({?periodEnd})-{TABLE.DATEFROM})<=3 Then 
    percentage:="33%"
Else 
    percentage:="-"

Any idea?

Aucun commentaire:

Enregistrer un commentaire