I have a table with a column month
(integer
). In this column I store values like 1, 2, .. 12
.
But I have to show the month name
There might be a quicker answer, but it seems to be possible by:
For example:
select to_char(to_timestamp(to_char(4, '999'), 'MM'), 'Mon')
returns 'Apr'.
You can turn it into a function:
create function to_month(integer) returns varchar as
$$
select to_char(to_timestamp(to_char($1, '999'), 'MM'), 'Mon');
$$ language sql
and use it throughout your code.
select to_month(month_column) from mytable