Drop decimals

1. Carlton G Guest

## Drop decimals

Newbie here;<BR><BR>I wanna be able to drop any decimals off a calculated value before I put it into a database. If I set the DB field to have no decimal places, the value will be put into the DB rounded. However, I have a requirement to drop the decimal places.<BR><BR>150.121 becomes 150<BR>150.5 becomes 150<BR>etc<BR><BR>I have an inclination that I have to use InStr, but I have not come up with the desired results.<BR><BR>Here is what I have:<BR><BR>Left(iNumber, (Len(iNumber) - InStr(iNumber, ".")))<BR><BR>Is this correct?<BR><BR>Thanks.<BR><BR>Carlton G

2. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## Use can use the instr and mid finctions

or<BR><BR>use the split function<BR><BR>a = split(iNumber, ".")<BR>iNumber = a(0)

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## Use MATH, not strings!

That&#039;s what the math functions in VBScript are *FOR*...to work with *NUMBERS*.<BR><BR>Look into how INT and FIX work. One of them is surely what you want.<BR><BR>And, no, your use of LEFT was wrong, anyway. <BR><BR>&#060;%<BR>strNum = CStr( iNumber )<BR>strNum = Left( strNum, InStr( strNum, "." - 1 )<BR>iNumber = CLng( strNum )<BR>%&#062;<BR><BR>All that to do what<BR>&#060;%<BR>iNumber = Int( iNumber ) <BR>%&#062;<BR>would do for you!<BR>

4. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## INT??? where was that hiding all this time

Never heard of it. Oh well guess today i did get something however small it is.<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•