Re: format integer

Поиск
Список
Период
Сортировка
От Steve Midgley
Тема Re: format integer
Дата
Msg-id CAJexoSLvrRxJrw6zEPU0-Xms0OBEeBFmXQ6HOgc8JMYw-36mjw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: format integer  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-sql


On Sun, Jan 24, 2021 at 8:06 AM David G. Johnston <david.g.johnston@gmail.com> wrote:

On Sunday, January 24, 2021, <ml@ft-c.de> wrote:

I need a integer format with different decimal places
The integer should have 6 diggits. (or 7 or 8)
 

No, there isn’t a function to apply this convoluted formatting rule to non-integer numbers.  You will need to write your own.

David J.

I've had to deal with something similar in the past, strangely. My solution was to convert the numeric formats to strings, and process there to get the right rule set regarding number of digits (and preserving all digits left of the period where required). Then convert back to your original numeric format. The one thing I'd mention as an edge case is that not all number systems use period as the significant digit delimiter, so be sure you guarantee the number formatting when you convert to string is what you expect when using this approach. I'd guess you could also solve this with logic and math (floor/ceiling/modulus, etc) but I found that using strings and regex was much easier for me.

Steve

В списке pgsql-sql по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: format integer
Следующее
От: Torge Kummerow
Дата:
Сообщение: Re: format integer