TeeJay
TeeJay

Reputation: 119

Crystal Report adding a year or month based on IF condition

I am trying to add a year to currentdate in Crystal Reports after a if condition (if a user renews a month it will add a month, a year it will add a year to current date), but it's not working. I created a date field type and in formula editor I put the below formula I tried the below

If {tblcustomers_1.Customertypeofpay}="yearly" then DateAdd("yyyy", 1, CurrentDate)) else 
DateAdd("mm", 1, CurrentDate))

I tried so many ways for date add and still not working please help.

Upvotes: 0

Views: 686

Answers (2)

MilletSoftware
MilletSoftware

Reputation: 3991

Most likely, your typeofpay field is numeric rather than text.

Upvotes: 0

MilletSoftware
MilletSoftware

Reputation: 3991

Change it to:

If {tblcustomers_1.Customertypeofpay}="yearly" then 
DateAdd("yyyy", 1, CurrentDate) else DateAdd("m", 1, CurrentDate)

You had extra ')' and extra 'm'.

Upvotes: 1

Related Questions