Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# removing everything after a decimal point

Posted on 2004-08-25
Medium Priority
130 Views
Hi all,
Quick question...how would I go about removing everything after a decimal point is encountered using CF?

Basically I have a value being returned from a query that is in floating point form, ie: 10.0
I need to only display this variable's whole number, ie: 10

How would I go about doing this?

Thanks,
Rick
0
Question by:bluskyGuy
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3
• 3
• 2
• +2

LVL 21

Accepted Solution

pinaldave earned 1200 total points
ID: 11897327
Hi bluskyGuy,
Hi bluskyGuy,
listfirst(yourstring,'.')
should do the work.

Regards,
---Pinal

===================================================================
Comment from pinaldave                    08/25/2004 02:03PM
===================================================================
Hi mostym,
<cfset YourList = "element1,element2,element3">

<cfoutput>
#ListFirst(YourList)#
</cfoutput>

you can do something like that... and if you have different delim then you can specify them in your string
Name: ListFirst()
Usage: ListFirst(list [, delimiters ])
Description: ListFirst() will return the first element in your list.

Regards,
---Pinal

Regards,
---Pinal
0

LVL 17

Expert Comment

ID: 11897775
#numberFormat("10.00", "________")#

is a better option, the data is not a list but a number..
0

LVL 21

Expert Comment

ID: 11897794
Hi bluskyGuy,
I will suggest to use suggestion of Tacobell as that is correct. Thanks buddy!

Regards,
---Pinal
0

LVL 17

Expert Comment

ID: 11899664
Try Fix() Or Int() functions available in CF

<CFOUTPUT>
#fix(10.00)#
#int(10.00)#
</CFOUTPUT>

as simple as it can be :)
0

Author Comment

ID: 11910481
Thanks all! First suggestion worked!
0

LVL 21

Expert Comment

ID: 11918681
Hi bluskyGuy,
if you do not need any more help you can close the question.

Regards,
---Pinal
0

LVL 18

Assisted Solution

Plucka earned 800 total points
ID: 11962889
Hi pinaldave,

Umm, there is a function for this, int take the integer portion of a number, ie drop the decimals, no reason to treat this as a list.

<cfset value="10.25" />
<cfoutput>#int(value)#</cfoutput>

Regards
Plucka
0

LVL 17

Expert Comment

ID: 11970371
Hey Plucka - nice to know that u agree with me :)
0

LVL 18

Expert Comment

ID: 12033985
anandkp,

Really if he agrees this is a good solution then you should have gotten the points. I think to often people just accept the first answer that works, regardless if it's the best answer.

I was just pointing out after he said the first solution worked that this wasn't the best solution.

Regards
Plucka
0

LVL 17

Expert Comment

ID: 12041298
WEIRD !!!

[totally agree with u Plucka ... cheers mate]
0

Author Comment

ID: 12041401
hi guys,
yea, I was just looking for speed-to-solution....i needed a solution ASAP although it necessarily wasn't the best solution.
Thanks,
bluskyguy
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice tā¦
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonstā¦
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrasā¦
###### Suggested Courses
Course of the Month9 days, left to enroll