473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

get number of digits

I need to get the number of digits in a variable number that may have anywhere from 3 to 6 digits. How do I find this?
Thanks!
Feb 7 '12 #1
2 7160
Stewart Ross
2,545 Expert Mod 2GB
Assuming that you are using an MS Access query and you are wanting to find the number of digits in a positive whole-number field, you can use the string function Len() to return the 'length' of the number as follows:

Expand|Select|Wrap|Line Numbers
  1. SELECT Len([Your Field Name Goes Here]) as Digits FROM YourTable;
Example of the use of Len() on the Inventory on Hold query of Northwind 2007:

Expand|Select|Wrap|Line Numbers
  1. Quantity On Hold  Digits
  2.         25        2
  3.         23        2
  4.        325        3
  5.        110        3
  6.         20        2
  7.         75        2
The SQL for this is just

Expand|Select|Wrap|Line Numbers
  1. SELECT [Quantity On Hold], Len([Quantity On Hold]) AS Digits
  2. FROM [Inventory on Hold];
-Stewart
Feb 7 '12 #2
Thanks for your reply! I figured out to use the Length function after posting the question.
Feb 7 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jovo Mirkovic | last post by:
Hi, I have to make a program which will generate 100,000 different ID numbers (for example 2345-9341-0903-3432-3432 ...) It must be really different, I meen it can not be a similar (like...
27
by: Luke Wu | last post by:
Is there a C function that returns the number of digits in an input int/long? example: numdigits(123) returns 3 numdigits(1232132) returns 7
18
by: Kuljit | last post by:
I am doing Engineering(B.Tech) in Computer Science. I have a question for which i am struggling to write a C code(program). It struck me when we were being taught about a program which counts the...
109
by: jmcgill | last post by:
Hello. Is there a method for computing the number of digits, in a given numeric base, of N factorial, without actually computing the factorial? For example, 8! has 5 digits in base 10; 10! has...
4
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I am trying to convert the digits to even number so for example if I have 3 digit number, I want it to be 4 digit and If I have 5 digit number, I want it to be 6 digit. How can i...
0
by: John Doe77 | last post by:
Hi, Given a phone number I need to print out all the word representation combinations possible from that phone number. Digits translate into chars like the following: 1 = 1 2 = A B C 3 = D E...
20
by: jacob navia | last post by:
Hi "How can I round a number to x decimal places" ? This question keeps appearing. I would propose the following solution #include <float.h> #include <math.h>
0
by: zephyrus360 | last post by:
This is about a technique to find the mod of a very large integer with a normal small integer. I recently encountered this problem when I needed to compute the modulus of a very large number with...
1
by: jlt206 | last post by:
This code <?php include("counter.php")?> on the webpage produces the count number. (function code below) I want to place the current number into a variable $MemberNo or into a FormField to be sent...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.