Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting 'Double' numbers to constant length in Access Query 1

Status
Not open for further replies.

VBAguy22

IS-IT--Management
Aug 5, 2003
180
CA
Hello there,
I have a table and one of the columns is decimal numbers. Say:

0.123456
1.55
21.21.21111111111

Now, I need to export that column to a text file formatting all the numbers above to 10.8 format. Which means, total of 10 characters, where the last 8 are after decimal point. We also need to omit the decimal point (whoever programmed in Mainframe: I basically need those numbers in D10.8).
I need a query expression to do it.

So the numbers above will become:
0012345600
0155000000
2121211111
As you can see, the last 8 digits are AFTER the decimal, and there is no actual decimal point character in the string.
I had no problem formating the text values of other columns by using Len(). But numbers seem to be more of a pain. Help please:(
 
Hi,

1) Multiply each value by 10^8

2) get the INTEGER part
[tt]
Int(Value * 10^8)
[/tt]
3)Pad to 10 characters
[tt]
Left("000000000", 10-len(Int(Value * 10^8))&Int(Value * 10^8)
[/tt]


Skip,

[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue]
 
And what about simply this ?
Format(100000000*[Value],"0000000000")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top