Forums

ASP

This topic is locked

Using the ROUND function in VBScript

Posted 30 Jan 2003 15:57:34
1
has voted
30 Jan 2003 15:57:34 Phil Grimpo posted:
I have a situation where billing is done per every 2 weeks of an event. So, of someone has a 5 week event, we need to bill for 6 weeks. Make sense? Well, using the round function, it will round to the closest "even" number. In the case of 5 weeks, the round function will return a 4. Now, my little fix was to actually add 0.5 to the number of weeks, and then do the round function. Is there any other / better way to do this? "Like a Round Up To Even"

-Grimps

Phil Grimpo
Executive Director
Inspirmedia

Replies

Replied 30 Jan 2003 16:20:48
30 Jan 2003 16:20:48 Julio Taylor replied:
why not make a variable which contains the return value of the round function + 1? this is similar to your idea, except you don't need to currupt your data and you're calculating data on the front end and not storing anything on db.

------------------------
Julio

PHP | MySQL | DWMX | ColdFusion

ICQ: 19735247
Replied 30 Jan 2003 16:22:45
30 Jan 2003 16:22:45 Phil Grimpo replied:
Because let's say the weeks is exactly 2 and the round function returns a 2, then I don't want to add 1, I just want to keep the 2 <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>

Phil Grimpo
Executive Director
Inspirmedia
Replied 23 Mar 2006 19:50:43
23 Mar 2006 19:50:43 John Shipp replied:
try this:

<pre id=code><font face=courier size=2 id=code>
if numOfWeeks mod 2 = 0 then
' here, the number of weeks is even
numOfWeeksToBill = numOfWeeks
else
' here, the number of weeks is odd so add one to round up
numOfWeeksToBill = NumOfWeeksToBill + 1
end if
</font id=code></pre id=code>

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I have a situation where billing is done per every 2 weeks of an event. So, of someone has a 5 week event, we need to bill for 6 weeks. Make sense? Well, using the round function, it will round to the closest "even" number. In the case of 5 weeks, the round function will return a 4. Now, my little fix was to actually add 0.5 to the number of weeks, and then do the round function. Is there any other / better way to do this? "Like a Round Up To Even"

-Grimps

Phil Grimpo
Executive Director
Inspirmedia
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote> <pre id=code><font face=courier size=2 id=code> </font id=code></pre id=code> <pre id=code><font face=courier size=2 id=code> </font id=code></pre id=code> <pre id=code><font face=courier size=2 id=code> </font id=code></pre id=code> <pre id=code><font face=courier size=2 id=code> </font id=code></pre id=code>

Reply to this topic