0

Is there any way to format timestamp to the following format in PostgreSQL?

2019-10-14T16:16:47.026Z
2
  • to_char() Commented Oct 25, 2019 at 11:46
  • I tried that but I can't get time with that Z at the end. Commented Oct 25, 2019 at 11:47

1 Answer 1

1

I believe you want:

select to_char(col, 'YYYY-MM-DD"T"HH:MI:SS.MSTZ')

Of course, the timezone depends on the timezone for the value.

Sign up to request clarification or add additional context in comments.

2 Comments

it gives "syntax error" for current situation. I need the same solution, please.
cursor.execute("SELECT to_char(time, 'YYYY-MM-DD"T"HH:MI:SS.MSTZ),temperature FROM conditions WHERE time > NOW() - interval '1000 days';")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.