Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: IF Stament and Formula Combination Post Reply Post New Topic
Author Message
crystalsonic
Groupie
Groupie


Joined: 26 Jan 2012
Online Status: Offline
Posts: 46
Quote crystalsonic Replybullet Topic: IF Stament and Formula Combination
     Posted: 13 Feb 2013 at 6:28am

I have Episodes.textTimeColl which is a text field string (4 characters long) that I am converting to time using the following formula Time Coll Format:

CTime(Picture({Episodes.textTimeColl}, "xx:xx"))

Then I take @Time Coll Format and use it for this calculation TAT External:

DateDiff ("s",DateTimeValue ({Episodes.DateColl},{@Time Coll Format} ),
DateTimeValue ({Episodes.ReportDate},{Episodes.ReportTime} ))/60/60

TAT Coll Format and TAT External display on the report.

I need to introduce an IF statement when Episodes.textTimeColl = "0000" (4 zeros) for two purposes:
1. Time Coll Format display as "Not Given"
2. Stop the TAT External calculation from taking place

I tried combining the IF statement with the @Time Coll Format calculation with no success. Where would be the best place to introduce the IF Statement? What would be the correct syntax?

THANKS!!!!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 13 Feb 2013 at 7:21am
you cannot return a string or a number into one formula result nor can you really stop the row from evaluating.
do you want to zero out the time difference?
 
if {Episodes.textTimeColl}="0000" then 0 else
DateDiff ("s",DateTimeValue ({Episodes.DateColl},{@Time Coll Format} ),
DateTimeValue ({Episodes.ReportDate},{Episodes.ReportTime} ))/60/60
 
for your display issue you can right click on the field
select format field
common tab
display string formula
if currentfieldvalue=0 then 'Not given' else totext(currentfieldvalue)


Edited by DBlank - 13 Feb 2013 at 7:21am
IP IP Logged
crystalsonic
Groupie
Groupie


Joined: 26 Jan 2012
Online Status: Offline
Posts: 46
Quote crystalsonic Replybullet Posted: 13 Feb 2013 at 10:08am
Zeroing out the difference worked fine. All working great!
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