1

I want a specific time format in Oracle SQL. The format is 2018-05-17T10:15:12-0300. Can anyone help me. I tried this but the last '-0300' is not reflecting in my result

Select to_char(systimestamp,'yyyy-mm-dd"T"hh:mm:ss"-Z"') from dual;
2
  • 1
    Please post the code you tried and the issues with it Commented Jun 1, 2018 at 11:03
  • Read about TO_CHAR() and DATETIME format models. Commented Jun 1, 2018 at 11:07

1 Answer 1

3

You can use the the format model YYYY-MM-DD"T"HH24:MI:SSTZHTZM, for instance

SELECT TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SSTZHTZM') FROM DUAL;

2018-06-01T13:04:44+0200 

The date format models are explained in Oracle's SQL Language Reference.

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

3 Comments

Every Time I Run this query i get 0000 after +. Can you tell me what is the reason for this. For Example - 2018-06-04T08:04:07+0000
TZH is the hours of the time zone, TZM the minutes. For instance, my example database is set to +0200, for Central European Summer Time, which is UTC + 2 hours. You can check your database with SELECT DBTIMEZONE FROM DUAL;
@hemantsingh Glad to her it! If the answer was ok, you might want to accept it, so that everybody else doesn't need to try to look for an answer for it...

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.