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!

Why is a time of midnight omitted from the display when converting to_date using hh24:mi:ss ?

Stephen ThompsonAug 10 2021

I have a to_date function to convert a string of date and time into a date type when inserting into my table.
For almost all of the dates and times this works as I want it to, with the time component shown as below:
select to_date('22-Nov-2020 17:30:41','dd-MON-yyyy hh24:mi:ss') from dual;
Result: 22/11/2020 17:30:41
However, on the occasions that the time is exactly midnight (and this happens once each day as the data is coming from a roadside speed tracking device) then the time section is missed out of the display as below:
select to_date('22-Nov-2020 00:00:00','dd-MON-yyyy hh24:mi:ss') from dual;
Result: 22/11/2020
Can anybody explain why please? I have tried searching online but I am left scratching my head. I thought 00:00:00 was a valid time.

This post has been answered by mathguy on Aug 10 2021
Jump to Answer
Comments
Post Details
Added on Aug 10 2021
6 comments
759 views