Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Using IF-THEN to calculate a field Post Reply Post New Topic
Author Message
CarlyTD
Newbie
Newbie


Joined: 29 Aug 2010
Location: United States
Online Status: Offline
Posts: 2
Quote CarlyTD Replybullet Topic: Using IF-THEN to calculate a field
     Posted: 29 Aug 2010 at 9:49am
Hi,

I am new to Crystal and have gotten myself in over my head.

I am trying to calculate a field based on three fields, and thought I could use some IF-THEN logic but am not figuring it out.  Specifically, I want to calculate a total number of days based on three different date fields.  I was hoping to use a formula field and have it:


If {DATE2} <= {DATE3} then {TOTAL_DAYS} = {DATE3}-{DATE1} + 1

else {TOTAL_DAYS} = {DATE3}-{DATE1} - 1

When I try to save the formula field, Crystal does not like my IF-THEN...

Can I use this logic in a formula field or is this not possible?

I would appreciate any thoughts...

Thanks
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Aug 2010 at 4:01am
datediff('d',date1,date3) +
(if date2<=date3 then 1 else (-1))
IP IP Logged
CarlyTD
Newbie
Newbie


Joined: 29 Aug 2010
Location: United States
Online Status: Offline
Posts: 2
Quote CarlyTD Replybullet Posted: 30 Aug 2010 at 12:55pm
Thanks very much..
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum