From: | "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Looking for a doc section that presents the overload selection rules |
Date: | 2021-10-22 21:09:48 |
Message-ID: | YXMonFWzb8tNNnUo@hjp.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2021-10-22 10:26:38 -0700, Bryn Llewellyn wrote:
> There could, so easily, have been three “to_char()” overloads for these three
> data types that honored the spirit of the “::text” typecast by rendering only
> what’s meaningful, despite what the template asks for.
I think to_date() is very much intended to produce fixed-width output
even when that makes little sense given the input data. For example:
hjp=> select to_char(3::int, '999.999');
╔══════════╗
║ to_char ║
╟──────────╢
║ 3.000 ║
╚══════════╝
(1 row)
An int has no fractional part, but I asked for 3 digits after the
decimal point so I got them.
hjp=> select to_char(34567::int, '999.999');
╔══════════╗
║ to_char ║
╟──────────╢
║ ###.### ║
╚══════════╝
(1 row)
34567 doesn't fit into the 3 digits before the point I asked for, so I
just get hashes.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp(at)hjp(dot)at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
From | Date | Subject | |
---|---|---|---|
Next Message | TIM CHILD | 2021-10-22 23:01:14 | Re: Strange sequences - how to construct? |
Previous Message | SQL Padawan | 2021-10-22 19:29:58 | Strange sequences - how to construct? |