0

I want to change the date format in PostgreSQL to be like this:

2019-03-21T00:00:00.

When I try

to_char(timestamp, 'YYYY-MM-DD"T"HH24:MI:SS')

I got this:

07/04/19 00:00

Also, if I change the format to be YYYY-MM-DD''T''HH24:MI:SS, e.g. to put two single quotes in each side of "T"

I get

2019-04-07'T'00:00:00

Thanks

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
  • 1
    it works fine with me, check the online demo also it works fine https://rextester.com/VXV82741 – Youcef LAIDANI Apr 07 '19 at 14:04
  • `to_char(timestamp, 'YYYY-MM-DD"T"HH24:MI:SS')` will work as you expect assuming that `timestamp` is indeed a timestamp column. –  Apr 07 '19 at 14:29
  • 1
    @YCF_L I believe you have put *double* quotes around the `T` (which works), while the asker had tried *two single* quotes on either side (and reported that it didn’t work as desired). Thanks for showing a working solution. – Ole V.V. Apr 07 '19 at 14:34
  • Oh @Ole V.V. I didn't notice this ☺ – Youcef LAIDANI Apr 07 '19 at 15:29

0 Answers0