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!

How do i convert a portion of day into a time?

Brian TkatchFeb 16 2012 — edited Feb 16 2012
How do i convert a portion of day into a time, without dividing and modding the number myself?

For example, i calculated solar noon UTC to be .733409047. Adding that to the date gives the correct answer:

SQL> SELECT TO_DATE('1/1/2012', 'DD/MM/YYYY') + .733409047 FROM Dual;

TO_DATE('1/1/2012',
-------------------
01/01/2012 17:36:07

A few questions, to actually understand this.

Is .733409047 implicitly converted? If so, to what datatype?
If i want HH:MM:SS does it need to be converted to a date, and then TO_CHAR? Or can the decimal be directly converted?

I'm currently trying to understand INTERVAL.

SQL> select interval '.5' day from dual;
select interval '.5' day from dual
*
ERROR at line 1:
ORA-01867: the interval is invalid

So, i'm obviously misunderstanding it. Can it be used here?
This post has been answered by Frank Kulash on Feb 16 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 15 2012
Added on Feb 16 2012
9 comments
320 views