Skip to main content
Inspiring
September 29, 2009
Question

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

  • September 29, 2009
  • 1 reply
  • 1011 views

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?

Thanks in advance,

DJ Khalif

This topic has been closed for replies.

1 reply

Inspiring
September 29, 2009

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.

djkhalifAuthor
Inspiring
September 29, 2009

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

September 29, 2009

"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.