Subject Re: [IBO] How to Format a FLOAT field?
Author Paulo Carvalho
Hi Marco,

Do already try use the FireBird function "round"?
This function have two parameters:
1º - the Field (a double value)
2º - number of precision

Ex: select round(num,2) from tableX where ...

if the "num" is 12.2156523123 this select retrive 12.21

Regards,


[Português]
Oi Marcos,

Você já tentou usar a função "round" do FireBird?
Esta função recebe dois parâmetros:
1º - o campo que você deseja selecionar (valor real)
2º - o numero de casas decimais que você deseja

Ex: select round(num,2) from tabelaX where ...

Se num valer 12.2156523123 o valor retornado pelo select será: 12.21

Blz?!

Paulo Sérgio Carvalho
Tecnologia de Informação

Engeman EAM Ltda
paulo@...
http://www.engeman.com.br
++ 55 (037) 3241 - 1084

----- Original Message -----
From: marcoandrecarvalho
To: IBObjects@yahoogroups.com
Sent: Thursday, February 24, 2005 3:39 PM
Subject: [IBO] How to Format a FLOAT field?



Hi All!

I want to format a float field with 2 decimals, ex.: 12.2156523123,
converted = 12.21. I tried to use
IB_Connection.FieldsDisplayFormat := 'TEST=0.00' and
IB_Connection.FieldEntryTypes = fetDomainName, but it gives me this
error: "EConvertError with message "xxxx" is not a valid integer
value".

I also tried to use CalculateFields, but without success either:

IB_Query1.CalculatedFields := 'TEST FLOAT NOT NULL' with the
following event:

procedure TDataModule1.taTestCalculateField(Sender: TIB_Statement;
ARow: TIB_Row; AField: TIB_Column);
begin
if AField.FieldName = 'GANHO' then
AField.AsString := FormatFloat('##0.00',ARow.ByName
('TEST').AsFloat);
end;

Can anyone give me a tip? What i´m doing wrong?

[]s, Marco André





___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !


Yahoo! Groups Sponsor
ADVERTISEMENT





------------------------------------------------------------------------------
Yahoo! Groups Links

a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/IBObjects/

b.. To unsubscribe from this group, send an email to:
IBObjects-unsubscribe@yahoogroups.com

c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



[Non-text portions of this message have been removed]