Can you format a
TIMESTAMP WITH TIME ZONE column in a
CREATE TABLE default constraint in Postgres v10.x?
create_date TIMESTAMP WITH TIME ZONE DEFAULT to_char(current_timestamp, 'DD-MON-YYYY HH24:MI:SS') NOT NULL
When running this, I get the following error:
ERROR: column "create_date" is of type timestamp with time zone but default expression is of type text HINT: You will need to rewrite or cast the expression. SQL state: 42804
However, according to the Postgres Docs this type of formatting should be possible.
I've also tried casting this with the
to_timestamp() method, however, I get the following error:
ERROR: function to_timestamp(timestamp with time zone, unknown) does not exist HINT: No function matches the given name and argument types. You might need to add explicit type casts. SQL state: 42883