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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Leading zero's on format command 2

Status
Not open for further replies.

mel41g

Technical User
Jan 31, 2005
7
VE
I am trying to make a field in a query that is pulling a number amount from a table. Some of the number's include decimal places, some do not. I need the new format of the information to be 12 characters long, with no decimal places, however, the 2 right-most numbers of every record must represent decimal places. The number needs to be right aligned, with leading zeros. Any sugestions on how to do this?
 
SELECT Format(100*[yourField],'000000000000') As FormattedAmount

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi,

...2 right-most numbers of every record must represent decimal places

Are you going to do arithmetic on this new column?

If NOT then just create a string.
Code:
 Left("0000000000000",5-Len(Int([field]*100))) & Int([field]*100)


Skip,

[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue]
 
Hi,

...2 right-most numbers of every record must represent decimal places

Are you going to do arithmetic on this new column?

If NOT then just create a string.
Code:
 Left("0000000000000",12-Len(Int([field]*100))) & Int([field]*100)


Skip,

[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue]
 
I've got it. Thanks for your quick response!
 


PHV,

Why didn't I think of such simplicity! ==> *

Skip,

[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top