CPM
CPM

Reputation: 15

Removing Zeros After Decimal

I have a field that is defaulted to 4 places after the decimal point. The field's data type is Number, field size double, and the decimal places is set to 4. I cannot change these attributes.

When running a query, how do I drop the zeros for the following

Entered Data = 0.5000% Desired Output = .5%

Entered Data = 0.2500% Desired Output = .25%

Entered Data = 100% Desired Output = 100%

Is there an expression or function I can use?

Upvotes: 0

Views: 169

Answers (2)

Gustav
Gustav

Reputation: 55906

If you also wish 100% to be displayed correctly, you need something like this:

SELECT 
    Format([NumberField], IIf(t >= 1, "0%", ".##%")) AS TextValue
FROM
    YourTable

Upvotes: 0

Oleg Belousov
Oleg Belousov

Reputation: 529

You may use function Format$.

SELECT Format$([MyTable].[Data],".##%") AS [Desired]
FROM [MyTable];

Upvotes: 1

Related Questions