Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Format time to hhmm format

fe6ff3f7-f37c-4f76-8a5b-43059fa31726Apr 7 2015 — edited Apr 7 2015

Hello,

I am new to Oracle. I am writing a query which requires the time portion of a date time to be in the following 24 hour format hhmm. I have the following in my query

TO_CHAR(order.orderdate, 'HH24:MI') which gives me 00:30 for 12:30 AM. If I change it to TO_CHAR(order.orderdate, 'HH24MI')  I only get 30 I need it to be 0030.

I have tried CONCAT(SUBSTR(TO_CHAR(order.orderdate,  'HH24:MI'), 1, 2), SUBSTR(TO_CHAR(order.orderdate, 'HH24:MI'), 4, 2)) but that gives me the same results as above.

Does someone have a solution for this?

Thanks

Tom

This post has been answered by Frank Kulash on Apr 7 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 5 2015
Added on Apr 7 2015
4 comments
1,562 views