Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Suppress digits after decimal point if integer
Most likely, you'll have to create your own function to do this. Your code might look something like:
CREATE OR REPLACE FUNCTION my_truncate ( in_value NUMBER )
RETURN varchar2 IS
BEGIN
/* is the input an integer? */
IF (in_value = TRUNC(in_value) THEN
RETURN TO_CHAR(in_value);
ELSE
RETURN TO_CHAR(TRUNC(in_value,2));
END IF;
END;
But that was just off the top of my head. You should be able to come up
with something that will suit your purposes.
HTH,
Brian
orauser_at_my-deja.com wrote:
>
> Hello,
>
> Is it possible to have a to_char number format to only
> print the .xx part of a number, if it is not
> an integer?
>
> i.e, i want:
>
> 12345
> or 12345.66
> but never
> 12345.00
>
> Thanks in advance for your help.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
-- ======================================== Brian Peasland Raytheons Systems at USGS EROS Data Center These opinions are my own and do not necessarily reflect the opinions of my company! ========================================Received on Wed Nov 15 2000 - 10:12:37 CST