1

What I'm trying is

SELECT TO_CHAR(NOW(), 'YYYY-MM-DDTHH24:MI:SS.US');

Actual Output:

           to_char            
------------------------------
 2021-06-17THH24:05:19.815403


but my Expected output:

           to_char            
------------------------------
 2021-06-17T06:05:19.815403


here When I use T then hour print like HH24.

1 Answer 1

2

Try placing the T between double quotes:

SELECT to_char(now(), 'YYYY-MM-DD"T"HH24:MI:SS.US');
          to_char           
----------------------------
 2021-06-17T08:11:11.913287
Sign up to request clarification or add additional context in comments.

4 Comments

one more thing, what does T represent in the datetime and what is US?
@GT T is a string you've chosen and US means microsecond (000000-999999). Check this tutorial: postgresqltutorial.com/postgresql-to_char
So there is no specific meaning of T. Thank you
@GT well, at least I'm not aware of T and the to_char tutorial does not mention it. But I cannot speak for the whole standard :) cheers and happy coding.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.