I'm working in postgresql and I need to convert the date format in query itself,
in mysql there is option called DATE_FORMAT
and I can use a query like this:
Select DATE_FORMAT(date_time, '%b %e, %Y, %T') from table_name
is there any option in postgresql? Please let me know if any?
If I modify your
to
it will return
Aug 21, 2012, 16:51:30
.You can do the same thing in Postgresql:
will return you
Aug-21-2012,16:08:08
Hope your problem is sort out.
Use to_char():
http://www.postgresql.org/docs/current/static/functions-formatting.html
I don't know what
'%b %e, %Y, %T'
produces as an output (and you didn't supply a sample output), so I cannot give you the equivalent format mask for Postgres.The following produces an ANSI date:
to_char
, eg:Try this