to_char(0,'FM999.99') outputs 0.

Started by Nonameover 23 years ago5 messagesgeneral
Jump to latest
#1Noname
sav@tut.by

Hi All,
I know this question has already been here but still...

select to_char(1,'FM999.99')
1

select to_char(0,'FM999.99')
0.

and now I want to get rid of that trailing point !
if this bug hasn't been fixed yet, then what is the best workaround?
should I say something like this:

select case when n = 0 then '0' else to_char(n,'FM999.99') end

Good luck!
Andrew Surinov

#2Bruce Momjian
bruce@momjian.us
In reply to: Noname (#1)
Re: to_char(0,'FM999.99') outputs 0.

I can see no reason that there is a period after 0 but not after 1.
Sure looks like a bug to me. Added to TODO:

* to_char(0,'FM999.99') returns a period, to_char(1,'FM999.99') does not

---------------------------------------------------------------------------

Andrew wrote:

Hi All,
I know this question has already been here but still...

select to_char(1,'FM999.99')
1

select to_char(0,'FM999.99')
0.

and now I want to get rid of that trailing point !
if this bug hasn't been fixed yet, then what is the best workaround?
should I say something like this:

select case when n = 0 then '0' else to_char(n,'FM999.99') end

Good luck!
Andrew Surinov

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Karel Zak
zakkr@zf.jcu.cz
In reply to: Bruce Momjian (#2)
Re: to_char(0,'FM999.99') outputs 0.

On Tue, Sep 03, 2002 at 01:01:26PM -0400, Bruce Momjian wrote:

I can see no reason that there is a period after 0 but not after 1.
Sure looks like a bug to me. Added to TODO:

* to_char(0,'FM999.99') returns a period, to_char(1,'FM999.99') does not

Oracle result:

SVRMGR> select to_char(0,'FM999.99') from dual;
TO_CHAR
-------
0.
1 row selected.

SVRMGR> select to_char(1,'FM999.99') from dual;
TO_CHAR
-------
1.
1 row selected.

You're right result of to_char(1,'FM999.99') in PG is bug.

There are more things in my TODO, but sorry I haven't time for 7.3. I must
finish some other project in this time. All will fixed in 7.4.

Karel

--
Karel Zak <zakkr@zf.jcu.cz>
http://home.zf.jcu.cz/~zakkr/

C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

#4Bruce Momjian
bruce@momjian.us
In reply to: Karel Zak (#3)
Re: to_char(0,'FM999.99') outputs 0.

Thanks for the update.

---------------------------------------------------------------------------

Karel Zak wrote:

On Tue, Sep 03, 2002 at 01:01:26PM -0400, Bruce Momjian wrote:

I can see no reason that there is a period after 0 but not after 1.
Sure looks like a bug to me. Added to TODO:

* to_char(0,'FM999.99') returns a period, to_char(1,'FM999.99') does not

Oracle result:

SVRMGR> select to_char(0,'FM999.99') from dual;
TO_CHAR
-------
0.
1 row selected.

SVRMGR> select to_char(1,'FM999.99') from dual;
TO_CHAR
-------
1.
1 row selected.

You're right result of to_char(1,'FM999.99') in PG is bug.

There are more things in my TODO, but sorry I haven't time for 7.3. I must
finish some other project in this time. All will fixed in 7.4.

Karel

--
Karel Zak <zakkr@zf.jcu.cz>
http://home.zf.jcu.cz/~zakkr/

C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#5Jeff Post
postjeff@uwm.edu
In reply to: Bruce Momjian (#4)
Re: to_char(0,'FM999.99') outputs 0.

I suggest that an additional pattern filter be created that that only
removes padding white space (front and back) and does not affect trailing
zeros. (like FM)

Regards,
Jeff Post

Show quoted text

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]On Behalf Of Bruce Momjian
Sent: Wednesday, September 04, 2002 2:09 AM
To: Karel Zak
Cc: Andrew; pgsql-general@postgresql.org
Subject: Re: [GENERAL] to_char(0,'FM999.99') outputs 0.

Thanks for the update.

------------------------------------------------------------------
---------

Karel Zak wrote:

On Tue, Sep 03, 2002 at 01:01:26PM -0400, Bruce Momjian wrote:

I can see no reason that there is a period after 0 but not after 1.
Sure looks like a bug to me. Added to TODO:

* to_char(0,'FM999.99') returns a period,

to_char(1,'FM999.99') does not

Oracle result:

SVRMGR> select to_char(0,'FM999.99') from dual;
TO_CHAR
-------
0.
1 row selected.

SVRMGR> select to_char(1,'FM999.99') from dual;
TO_CHAR
-------
1.
1 row selected.

You're right result of to_char(1,'FM999.99') in PG is bug.

There are more things in my TODO, but sorry I haven't time for

7.3. I must

finish some other project in this time. All will fixed in 7.4.

Karel

--
Karel Zak <zakkr@zf.jcu.cz>
http://home.zf.jcu.cz/~zakkr/

C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

--
Bruce Momjian                        |  http://candle.pha.pa.us
pgman@candle.pha.pa.us               |  (610) 359-1001
+  If your life is a hard drive,     |  13 Roberts Road
+  Christ can be your backup.        |  Newtown Square,
Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly