Calculate Outstanding Days

I’m trying to have a field that calculates how long a document hasn’t been closed by a due date.Field:

DueDate - Time\Date - Computed for Display

with value: @Adjust(DateRaised ; 0 ; 0 ; 30 ; 0 ; 0 ; 0 )

DateNow - Time\Date - Computed for Display

with value: @Now

DaysOS - Number - Computed for Display

with value: @IsNumber(DateNow-DueDate/864000)

The DaysOS field doesn’t calculate the number of days, it only displays a zero. Before I added the @IsNumber I kept getting number expected error.

I have tried different combinations but just can’t get it right.

Appreciate some help.

Marion

Subject: BODMAS

Some basic maths. Order of calculation is:Brackets

Operands

Division

Multiplication

Addition

Subtraction

Hence - BODMAS.

There are two errors in your final formula “@IsNumber(DateNow-DueDate/864000)”

Firstly, the bit inside the bracket is trying to divide DueDate by 86400, and then subtract the result of that from DateNow. That’s why you were getting your “number expected” error.

What you meant was (DateNow-DueDate)/86400

The second error is using @IsNumber. That returns @True or @False, which in a number field equate to 1 and 0 respectively. your formula in tnside the brackets produced an error, not a number, so @IsNumber was false, so you got a zero.

So, just change your formula for DaysOS to (DateNow-DueDate)/86400 and your sorted. Ideally, you should add a check to make sure that the other fields exist, so that you don’t get an error if one of them doesn’t. Also, you could just use (@Now-DueDate)/86400 and delete the DateNow field.

Hope this helps,

Phil

Subject: Don’t display negative value

Hi Phil,Thanks for your response. I changed the formula to (@Now-DueDate)/86400 which is working.

Can you please tell me if it is possible to hide the value if it is negative.

Thanks… Marion

Subject: A couple of suggestions

There are lots and lots of ways of doing this. Here are two of the simplest:

temp := (@Now-DueDate)/86400;

@If(temp<0; 0; temp)

or

@If(@Now < DueDate ; 0 ; (@Now-DueDate)/86400)

Hope this helps,

Phil

Subject: Great !! Thanks for your help