# Thread: How to find the length of a BIGINT?

1. Registered User
Join Date
Jul 2006
Posts
13

## Unanswered: How to find the length of a BIGINT?

I think in order to do this, I have to convert the BIGINT to a varchar first, but how?

2. Registered User
Join Date
Sep 2003
Posts
237
if you are cocerned about how many bytes a bigint takes, it is always 8 and it can represent a number with 19 digits.

3. Registered User
Join Date
Jul 2006
Posts
13
Originally Posted by dbamota
if you are cocerned about how many bytes a bigint takes, it is always 8 and it can represent a number with 19 digits.
I have a column in a table that is of type BIGINT. However the values doesnt always have the same number of digits, it can contain 11 or 13 digits (e.g. 91310140001). I need to be able to distinguish which rows contain 11 or 13 digits, which is why I want to find the length.

4. :-)
Join Date
Jun 2003
Location
Posts
5,516
That reminds me of a guy who did this in java:
Code:
`if (Boolean.valueOf(someBooleanValue).toString().length() < 5) ...`
Don't they teach arithmetics in universities anymore?

5. Registered User
Join Date
Sep 2003
Posts
44
Will this work? SELECT LENGTH(STRIP(CHAR(YOUR_BIGINT_COLUMN))) ...

6. Registered User
Join Date
May 2003
Location
USA
Posts
5,737
Originally Posted by Yukke
I have a column in a table that is of type BIGINT. However the values doesnt always have the same number of digits, it can contain 11 or 13 digits (e.g. 91310140001). I need to be able to distinguish which rows contain 11 or 13 digits, which is why I want to find the length.
When you say number of digits, I assume you are excluding leading zeros?

If that is the case, any value > 99999999999 must have more than 11 "digits" (as you call them).

To distinguish them, you can use the case statement, where clause, if statement in a proc or function, etc.

7. Registered User
Join Date
Dec 2005
Posts
273
consider using:

FLOOR(LOG10(your_column))+1

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•