Solved Format Number Field in Select Statement (1 Viewer)

Drand

Registered User.
Local time
Today, 12:22
Joined
Jun 8, 2019
Messages
179
Hi

Could someone please show me the correct syntax to format the field [CountryCode] in the following select statement to zero decimal places?

Code:
SELECT [qryCountriesWithMissingData].[Member Firm], [qryCountriesWithMissingData].[CountryCode], [qryCountriesWithMissingData].[No of Records] FROM qryCountriesWithMissingData ORDER BY [Member Firm];

I am using this in a list box that is currently displaying 2 decimal places which I do not want.

Much appreciated and thanks
 

plog

Banishment Pending
Local time
Yesterday, 21:22
Joined
May 11, 2011
Messages
11,653
Int() will give you just the integer portion of a number:


If there are leading zeros though, you probably want to find the position of the decimal with Instr()


And Mid() to get everything before it:

 

Drand

Registered User.
Local time
Today, 12:22
Joined
Jun 8, 2019
Messages
179
Thanks for your response. I am not sure I understand what you are saying though.

What I am trying to do is something like Format (CountryCode, "#,##0") but I am trouble with the syntax within the select statement
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:22
Joined
May 7, 2009
Messages
19,247
Format([CountryCode], "#")
 

Drand

Registered User.
Local time
Today, 12:22
Joined
Jun 8, 2019
Messages
179
Thanks arenlgp. Where would I place this in the select statement?

I tried

Code:
SELECT [qryCountriesWithMissingData].[Member Firm], Format( [qryCountriesWithMissingData].[CountryCode],"#"), [qryCountriesWithMissingData].[No of Records] FROM qryCountriesWithMissingData ORDER BY [Member Firm];

This formats the number correctly but now the column head is showing expr1001.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:22
Joined
May 7, 2009
Messages
19,247
try:

Format( [qryCountriesWithMissingData].[CountryCode],"#") As [Country Code]
 

Drand

Registered User.
Local time
Today, 12:22
Joined
Jun 8, 2019
Messages
179
Perfect!

Thank you very much, greatly appreciated.
 

JonXL

Active member
Local time
Yesterday, 21:22
Joined
Jul 9, 2021
Messages
153
Seems like the real issue is you have something that isn't a number stored in a numeric data type.
 

Users who are viewing this thread

Top Bottom