Solved

removing everything after a decimal point

Posted on 2004-08-25
11
124 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
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 21

Accepted Solution

by:
pinaldave earned 300 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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 200 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 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