user1535219
user1535219

Reputation: 31

nls_date_format for postgres

We are trying to port a couple of decades worth of Oracle code to Postgres.

Our Oracle code sets NLS_DATE_FORMAT = 'mm/dd/yy', which has the nice effect that whenever a date column appears in a select statement, it is automatically formatted "mm/dd/yy".

The closest I can find to that in Postgres is SET DATESTYLE TO SQL,US; but that causes date fields to be returned like " 07/17/2012 16:41:42.109852 EDT".

Yes, I can modify each of many hundreds of SQL statements to use to_char() or other casts, but does Postgres really not have this simple ability to customize the default output format for dates?

Upvotes: 3

Views: 3194

Answers (1)

user330315
user330315

Reputation:

No, PostgreSQL doesn't have such a setting.

Relying on a NLS_DATE_FORMAT (and thus implicit data conversion) in Oracle was a bad choice to begin with. So take the chance and get your SQL code more solid.

Upvotes: 2

Related Questions