Is there a FORMAT Function?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
BLOMASKY
Posts: 1480
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Is there a FORMAT Function?

Post by BLOMASKY »

I have a need to create a string field, with a formatted number, sometimes with 2 decimal places, sometimes 0

It would look like

IF BO.X = 1000 then BO.A = FORMAT(BO.B, '#,##0.00') ELSE BO.A = FORMAT(BO.B, '#,##0')

Can I accomplish this in Aware?

Thanks
Bruce
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Is there a FORMAT Function?

Post by tford »

You'll need to explore the AS_STRING function.
Tom - V8.8 build 3137 - MySql / PostGres
BLOMASKY
Posts: 1480
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: Is there a FORMAT Function?

Post by BLOMASKY »

Thanks for the response, but I didn't think I can control the formatting with that. All it does is convert it to a string. Yea, I could then use some substring functions, but it seems like a format function could be pretty useful.

Bruce
RocketRod
Posts: 907
Joined: Wed Aug 06, 2008 4:22 am
Location: Melbourne

Re: Is there a FORMAT Function?

Post by RocketRod »

I haven't tested it but try adding different styles for the number. Add an applicability condition such as <1000 and with it a different format.

Cheers Rod
BLOMASKY
Posts: 1480
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: Is there a FORMAT Function?

Post by BLOMASKY »

Thanks for the suggestion, but I did try that, and unfortunatly, it didnt work. I still have the decimal points. (but, I would like to be more general, and able to be used in a process, so I can both format the number and also append other text to it.

Bruce
BobK
Posts: 546
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: Is there a FORMAT Function?

Post by BobK »

Never doubt Tom.

Try:
BO.A = AS_STRING(BO.B, '#,##0.00')
or
BO.A = AS_STRING(BO.B, '#,##0')
Bob
BenHayat
Posts: 2749
Joined: Thu Dec 23, 2010 5:48 am
Location: Fla, USA
Contact:

Re: Is there a FORMAT Function?

Post by BenHayat »

BobK wrote: Never doubt Tom.
I like that... Image
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Is there a FORMAT Function?

Post by tford »

You guys crack me up. My wife would likely give you a different answer.

I thought the syntax was what Bob indicated, but I had never used it. I just tested this rule and it works:

If Customer.Nbr>=1000 Then
Customer.Nbr_String=AS_STRING(Customer.Nbr,'#,##0.00')
ELSE Customer.Nbr_String=AS_STRING(Customer.Nbr,'#,##0')

I'll ask Vladimir to add some of this formatting info to the User Guide documentation of AS_STRING.
Tom - V8.8 build 3137 - MySql / PostGres
BLOMASKY
Posts: 1480
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

not working for me

Post by BLOMASKY »

I must be doing something wrong, since my rule is:

Quotes.priceString=AS_STRING(Quotes.actualPrice,'#,##0') + '/' + Quotes.perString

and when I display the priceString on a query, I will see: 2300.0/M

No commas and 1 decimal place. hummm...
Post Reply