Insert a decimal

  • Thread starter Thread starter Guest
  • Start date Start date
Are you saying you want to take an integer of variable length e.g. 1234567
and return 12.34567? If so one way would be:

NewNumber = OriginalNumber/10^(Int(log(OriginalNumber)/log(10))-1)

Ken Sheridan
Stafford, England
 
PS: It would also work if the original number is a floating point number.

Ken Sheridan
Stafford, England
 
how do I insert a decimal 2 spaces from the left?

What's the context? Do you want to take 3145 and get 31.45, 22458712 and get
22.458712 and so on? What's the datatype of the field?

John W. Vinson [MVP]
 
Thank you everyone for your feedback. For instance it currently is 1234567
however it should be 12345.67. Another example is 123400 it should read
1234.00. It is currently saved as a text file.
 
That's two digits from the right, not from the left, so it's simpler than
Ken's suggestion.

All you need to do is divide the number by 100.
 
That's two digits from the right

All you need to do is divide the number by 100.

Actually, I think they may want to multiply by 0.01 e.g.

SELECT 1234567 / 100 AS float_value, TYPENAME(1234567 / 100) AS
float_type,
1234567 * 0.01 AS decimal_value, TYPENAME(1234567 * 0.01) AS
decimal_type

In my experience, when someone specifies 'decimal' they are interested
in exact values. Dividing by 100 returns an approximate type.

Jamie.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Inserting decimal places 1
Access stripping decimal places in query 1
why are my decimals truncated? 3
Decimal Places 1
Decimal places in charts 4
decimals 6
decimal places 1
Decimal Places 1

Back
Top