Question

Here i have sql server query (creating view) as shown below:

Example:

create view v1 
as 
select distinct 
         table1.col1,table1.col2,table1.col3,
         table2.col1,table2.col2,table2.col3,
         CONVERT(varchar, table2.col4, 106) AS newcol, /*table2.col4 is datetime type*/
from table1;

Q: How to use convert() function used above in PostgreSQL?

Was it helpful?

Solution

Looks like you simply want TO_CHAR(), something similar to;

select distinct 
     table1.col1,table1.col2,table1.col3,
     table2.col1,table2.col2,table2.col3,
     to_char(table2.col4, 'DD mon YYYY') AS newcol,
...

An SQLfiddle to test with.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top