4 Replies Latest reply on Sep 29, 2009 7:52 AM by djkhalif

# <cfset FORM.UnitsProd = FORM.EndUnits - (FORM.StartUnits) + 1 >

Good morning all,

I am having a problem with this formula. <cfset FORM.UnitsProd = FORM.EndUnits - (FORM.StartUnits) + 1 >

When FORM.StartUnits = 1 then, my calculations are wrong. For instance, EndUnits and StartUnits represent serial numbers, which I can then, total as UnitsProd. If EndUnits = 3 and StartUnits = 1; I get 3 = 3-1+1. But, 15 = 60 - 46 +1. Would a cfif statement resolve this?

<cfset FORM.UnitsProd = FORM.EndUnits - (FORM.StartUnits) + 1 >

<cfif>

#FORM.StartUnits# = 1

<cfelse>

<cfset FORM.UnitsProd = FORM.EndUnits + FORM.StartUnits >

</cfif>

Does this make sense?

DJ Khalif

• ###### 1. Re: <cfset FORM.UnitsProd = FORM.EndUnits - (FORM.StartUnits) + 1 >

Does it make sense?  Not to me.

Maybe if you show us some numbers that include what you think the answer should be and what it actually is, it would more clear.

• ###### 2. Re: <cfset FORM.UnitsProd = FORM.EndUnits - (FORM.StartUnits) + 1 >

Dan,

UnitsProd = EndUnits - StartUnits + 1, (3 = 3 - 1 + 1). This should be 4

But,

UnitsProd =EndUnits - StartUnits +1, (15 = 60 - 46 +1) This is correct.

I hope this helps.

Thanks,

DJ Khalif

• ###### 3. Re: <cfset FORM.UnitsProd = FORM.EndUnits - (FORM.StartUnits) + 1 >

"UnitsProd = EndUnits - StartUnits + 1, (3 = 3 - 1 + 1). This should be 4"

I think you need to take your calculator back to the store - that's correct, it should be (and is) 3.

3 - 1 = 2

2 + 1 = 3

Or, to make it simpler, the "- 1" and "+ 1" cancel each other out, so it becomes:

3 = 3

Your app is running correctly, it's your verification calculations which are wrong.

• ###### 4. Re: <cfset FORM.UnitsProd = FORM.EndUnits - (FORM.StartUnits) + 1 >

Phil,

Thanks for the jab. However, I spoke too soon. As ugly as it looks it does work. I went back to look at the results and realized that; if I produced 1 unit then, my formula works properly. That's the basis for the whole thing. To put it plainly, I was trying solve what I solved.

Thanks,

DJ Khalif