I am converting a SQL Server stored procedure to a Postgres function. Two of the columns in the SQL Server table are MonthOfBirth and LifeOfBirth. They are both integer values. In SQL Server it is easy to combine these two columns like this:
CAST(MonthOfBirth AS VARCHAR(2)) + '/' + CAST(YearOfBirth AS VARCHAR(4))
I thought that maybe tochar() would work in Postgres, but it doesn't.
Could someone point me in the right direction?
Thanks
The direct translation of the SQL Server code is to use the standard concatenation operator
||
But this is a bit easier using
concat()
:If you need a leading zero for the month, use
to_char()