Interesting things I've learned: Roman numerals in Postgres
I have XCIX problems, but Roman numerals ain't one
There is a built-in way to convert numbers to Roman numerals in Postgres.
to_char
(docs) is a function in Postgres that converts a number to a string in a given format. One of the formats it supports is 'RN'
, which converts a number to a Roman numeral.
SELECT to_char(1234, 'RN');-- Returns "MCCXXXIV"
Note that it only supports numbers between 1 and 3999.
SELECT to_char(4000, 'RN');-- Returns ###############
Like this article? Follow me on Bluesky or subscribe to the RSS feed to get notified about new articles.