Reputation: 233
In Oracle DATE output format is set using NLS_DATE_FORMAT but in PostgreSQL it is not flexible to set the DATE output format like Oracle. In PostgreSQL DATE output format can be set using DateStyle but DateStyle values are limited so user can not change the DATE output format flexibly. To overcome this problem we can use to_char(). Is there any other way to set DateStyle or Create custom DateStyle output format?
Upvotes: 0
Views: 717
Reputation: 324265
You've already shown the options:
to_char
; or
DateStyle
, within the limits it allows.
Client applications are supposed to format dates. PostgreSQL just supplies a standard date in an easily parsed format for client drivers to read. In fact, if you use the binary protocol it just sends the date as a bigint.
If you feel strongly about this you could propose a patch to the pgsql-hackers mailing list adding the feature you desire. You will need to be willing to learn enough PostgreSQL back-end coding to implement this yourself, or to pay someone else to do it. I don't particularly see why DateStyle couldn't be extended to accept a format string, but I don't think anybody's cared enough to do the work (and patch all the client drivers to support it).
Upvotes: 1