NumberFormat woes
I feel a little silly about not being able to figure this out... I'm using CF 4.5.1 SP2. I have a list of numbers: 7, 10, 203, 8, 26, etc. I want the single digit numbers to display as two digits (07, 08, etc.). All other numbers should just display as they are (10, 203, 26, etc.). I've tried NumberFormat(mynumber, 00), but then I get an error if there's a three digit number. I've tried NumberFormat(mynumber, 999), but that doesn't display the single digits as two digits. I've tried NumberFormat(mynumber, 900), but that displays the single digits with two leading zeros. I've tried other, similar combinations as well - all with no success. Any ideas? Thanks, Evan -- -=-=-=-=-=-=-=-=-=- Evan Lavidor Circle.com Boston Tel: 617-585-3107 Fax: 617-585-3091 -=-=-=-=-=-=-=-=-=- ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: NumberFormat woes
cfif num lte 9cfset num = 0#num#/cfif This gives you a string though, so do any calculations before output. - Original Message - From: Evan Lavidor [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Monday, April 30, 2001 11:36 AM Subject: NumberFormat woes I feel a little silly about not being able to figure this out... I'm using CF 4.5.1 SP2. I have a list of numbers: 7, 10, 203, 8, 26, etc. I want the single digit numbers to display as two digits (07, 08, etc.). All other numbers should just display as they are (10, 203, 26, etc.). I've tried NumberFormat(mynumber, 00), but then I get an error if there's a three digit number. I've tried NumberFormat(mynumber, 999), but that doesn't display the single digits as two digits. I've tried NumberFormat(mynumber, 900), but that displays the single digits with two leading zeros. I've tried other, similar combinations as well - all with no success. Any ideas? Thanks, Evan -- -=-=-=-=-=-=-=-=-=- Evan Lavidor Circle.com Boston Tel: 617-585-3107 Fax: 617-585-3091 -=-=-=-=-=-=-=-=-=- ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: NumberFormat woes
If all you want to do is display it with a 0 in front, but want to keep it a number for calculations and such, than just do this cfif len(num) eq 1 0#num# cfelse #num# /cfif It'll check to see if it's only 1 digit, and if so, it'll place that 0 in front. Otherwise, just display the number. That way, they'll stay numbers, and not become strings. Stuart Duncan MaracasMedia Inc. At 04:16 PM 4/30/01 -0400, you wrote: irrelevant... you can do calculations via val(string). or you can do cfset like so: cfset num = 0 num and cf creates a num usable in a calculation. at least in vs.4.5.2. Alexander Sicular Chief Technology Architect The Neurological Institute of New York Columbia University 212.305.1318 as867 {at} columbia [dot] edu -Original Message- From: stas [mailto:[EMAIL PROTECTED]] Sent: Monday, April 30, 2001 12:49 PM To: CF-Talk Subject: Re: NumberFormat woes cfif num lte 9cfset num = 0#num#/cfif This gives you a string though, so do any calculations before output. - Original Message - From: Evan Lavidor [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Monday, April 30, 2001 11:36 AM Subject: NumberFormat woes I feel a little silly about not being able to figure this out... I'm using CF 4.5.1 SP2. I have a list of numbers: 7, 10, 203, 8, 26, etc. I want the single digit numbers to display as two digits (07, 08, etc.). All other numbers should just display as they are (10, 203, 26, etc.). I've tried NumberFormat(mynumber, 00), but then I get an error if there's a three digit number. I've tried NumberFormat(mynumber, 999), but that doesn't display the single digits as two digits. I've tried NumberFormat(mynumber, 900), but that displays the single digits with two leading zeros. I've tried other, similar combinations as well - all with no success. Any ideas? Thanks, Evan -- -=-=-=-=-=-=-=-=-=- Evan Lavidor Circle.com Boston Tel: 617-585-3107 Fax: 617-585-3091 -=-=-=-=-=-=-=-=-=- ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: NumberFormat woes
irrelevant... you can do calculations via val(string). or you can do cfset like so: cfset num = 0 num and cf creates a num usable in a calculation. at least in vs.4.5.2. Alexander Sicular Chief Technology Architect The Neurological Institute of New York Columbia University 212.305.1318 as867 {at} columbia [dot] edu -Original Message- From: stas [mailto:[EMAIL PROTECTED]] Sent: Monday, April 30, 2001 12:49 PM To: CF-Talk Subject: Re: NumberFormat woes cfif num lte 9cfset num = 0#num#/cfif This gives you a string though, so do any calculations before output. - Original Message - From: Evan Lavidor [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Monday, April 30, 2001 11:36 AM Subject: NumberFormat woes I feel a little silly about not being able to figure this out... I'm using CF 4.5.1 SP2. I have a list of numbers: 7, 10, 203, 8, 26, etc. I want the single digit numbers to display as two digits (07, 08, etc.). All other numbers should just display as they are (10, 203, 26, etc.). I've tried NumberFormat(mynumber, 00), but then I get an error if there's a three digit number. I've tried NumberFormat(mynumber, 999), but that doesn't display the single digits as two digits. I've tried NumberFormat(mynumber, 900), but that displays the single digits with two leading zeros. I've tried other, similar combinations as well - all with no success. Any ideas? Thanks, Evan -- -=-=-=-=-=-=-=-=-=- Evan Lavidor Circle.com Boston Tel: 617-585-3107 Fax: 617-585-3091 -=-=-=-=-=-=-=-=-=- ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists