Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If negative then Zero--How?

Status
Not open for further replies.

BradB

MIS
Jun 21, 2001
237
US
I have a formula that returns a value. If the value turns out to be negative, I want it to return a zero. Any ideas on how to do that?
 
Where would I put that line of code? The formula can't reference itself within the formula.

Formula:
wdaysClass1wdLoadFile ("\\bertnash\Crystal Reports\Report\bwdays.txt");

//@BusinessDaysIncludingHolidays
//ENTER FIRST DAY
datevar startdate:= DateTimeToDate({TSTrack.DateOfSAL});
//ENTER LAST DAY
datevar enddate:= DateTimeToDate({TSTrack.DateRec});
//ENTER WORKING DAYS
stringvar workingdays:= "-23456-";
//---------------------------------------------------------
//calculate totalworkdays
if DayOfWeek(startdate)=1 or DayOfWeek(startdate)=7 then
numbervar totaldays:= wdaysclass1wdnumworkdays(startdate,enddate,workingdays)-1
else if startdate > enddate then 0
else if startdate = enddate then 0
else if {Staff.stf_salfreqy}="W" and CurrentDate>({TSTrack.DateOfSAL}+7) then
numbervar totaldays:= wdaysclass1wdnumworkdays(startdate,enddate,workingdays)-6
else
numbervar totaldays:= wdaysclass1wdnumworkdays(startdate,enddate,workingdays)-2
 
So if your formula is returning the value then try this:
If({@YourFormula}) < 0 then &quot;0&quot;
 
It must be the chinese food I just ate...The answer was right in front of my face. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top