?
Solved

removing everything after a decimal point

Posted on 2004-08-25
11
Medium Priority
?
129 Views
Last Modified: 2013-12-24
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
Comment
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
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 21

Accepted Solution

by:
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

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

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

Expert Comment

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

Regards,
---Pinal
0
Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

 
LVL 17

Expert Comment

by:anandkp
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

by:bluskyGuy
ID: 11910481
Thanks all! First suggestion worked!
0
 
LVL 21

Expert Comment

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

Regards,
---Pinal
0
 
LVL 18

Assisted Solution

by:Plucka
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

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

Expert Comment

by:Plucka
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

by:anandkp
ID: 12041298
WEIRD !!!

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

Author Comment

by:bluskyGuy
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
What You Need to Know when Searching for a Webhost Provider
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question