Sagewire Logo

leading zero

5 Message(s) by 3 Author(s) originally posted in cfml discussion


From: frank_tudor Date:   Wednesday, October 24, 2007
I have a query that pulls a set of values from a table . I need to create a loop
that updates the values in another table based on some conditions. Some of the
numbers have leading zeros that get truncated during the updated. How do I
prevent this from happening? What function do I wrap around the variable to
maintain leading zeros?

Thanks,
Frank


From: dacf Date:   Wednesday, October 24, 2007
My first thought is that the numbers are getting truncated in the update into
the data base... and that the column type in the database is a
Int/Double/Numeric.

Most database vendors (well Oracle and MySQL in my experience)'d perform
truncation at that point as the leading zeros mean nothing in the number.

If that is the case, you'd need to change the column data type to VARCHAR
or the likes to maintain the zeros in the database, or use
numberFormat(theNumber, "000000000") on your ColdFusion pages.


From: frank_tudor Date:   Wednesday, October 24, 2007
I am using oracle.....I'll give that a go...Thanks...


From: frank_tudor Date:   Wednesday, October 24, 2007
Ok that worked like a charm! Thanks again.

Frank


From: jdeline Date:   Wednesday, October 24, 2007
The code below will produce a 10-character string with leading zeros.

<CFSET foo = 123>
<CFSET bar= RepeatString(" ", 10 - Len(foo)) & foo>



Next Message: Help find if subdomain exists, then redirect


Blogs related to leading zero

string data right truncated on column number 1
... format java string format javascript string format leading zero string format leading zeros string format method string format money string format msdn string format net string format number string format numbers string format pad ...

String Conversion in CFGridColumn
Here's one... I have the following in my html grid, but there is one problem. Some of the PO Number for our customers have a leading zero, which the grid strips out for some reason. Any ideas on how to convert the PO number ...

QueryConvertForGrid removes leading zero
If the purchase order number (which can be alpha-numeric) has a leading zero, it will strip it out when it returns the values to the grid. Anyone have a suggestion that could resolve this problem? SELECT invoice, date_format(invDate, ...

Re: Excel output formatting??
On 10/18/07, Dae wrote: > > > > > > Is there any way to set the field type in excel when outputting to it > > > using > > > coldfusion? > > > > > > I ask this because when I have a number that has leading zeros, they > get > > > dropped ...

Re: QueryConvertForGrid removes leading zero
Write a function that returns the data in the same format the QueryConvertForGrid does, but keeps your leading zeros. I'd speculate that internally the function is doing a Query of Queries which may be treating these values as numbers ...

Excel output formatting??
Is there any way to set the field type in excel when outputting to it using coldfusion? I ask this because when I have a number that has leading zeros, they get dropped when output in excel. As an example lets say I have a table with ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional