Subject | Re: [firebird-support] Using Cast() to truncate? |
---|---|
Author | agung wibowo |
Post date | 2004-12-08T02:19:34Z |
hi,
if i'm not wrong DOUBLE PRECISION is floating point number, so whatever you input to the column with this type data, you still get floating point number, it mean that your "scale" is not fixed. then, maybe fine if you alter your column data type from DOUBLE PRECISION to NUMERIC(18,2) like you expected. but if you don't, you can retreive data with cast statement, like select cast(vpmsrp as numeric(18,2)) from vendorsproducts; so you get 2 decimal placest as your result.
sorry for my english.., i hope you can understand my idea. :))
regards,
agung
if i'm not wrong DOUBLE PRECISION is floating point number, so whatever you input to the column with this type data, you still get floating point number, it mean that your "scale" is not fixed. then, maybe fine if you alter your column data type from DOUBLE PRECISION to NUMERIC(18,2) like you expected. but if you don't, you can retreive data with cast statement, like select cast(vpmsrp as numeric(18,2)) from vendorsproducts; so you get 2 decimal placest as your result.
sorry for my english.., i hope you can understand my idea. :))
regards,
agung
----- Original Message -----
From: Joe Martinez
To: Interbase Support
Sent: Wednesday, December 08, 2004 6:21 AM
Subject: [firebird-support] Using Cast() to truncate?
I am trying to use the following update to multiply a field by 2.25, but I
want the resulting number (stored in vpmsrp, which is a DOUBLE PRECISION
field) to be truncated to 2 decimal places. The following query:
update vendorproducts set vpmsrp = cast((vpcost * 2.25) as numeric (18,2) )
however, doesn't work. I did the cast, hoping that by casting to a 18,2
data type, that it would truncate it, but that doesn't happen. The
resulting values of vpmsrp have more than 2 decimal places.
Why doesn't that work? And, how can I modify that statement to make it work?
-Joe
Yahoo! Groups Sponsor
Get unlimited calls to
U.S./Canada
------------------------------------------------------------------------------
Yahoo! Groups Links
a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/
b.. To unsubscribe from this group, send an email to:
firebird-support-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]