Evaluate the following query:
SELECT INTERVAL ‘300’ MONTH,
INTERVAL ’54-2′ YEAR TO MONTH,
INTERVAL ’11:12:10.1234567′ HOUR TO SECOND
FROM dual;
What is the correct output of the above query?
A.
+25-00 , +54-02, +00 11:12:10.123457
B.
+00-300, +54-02, +00 11:12:10.123457
C.
+25-00 , +00-650, +00 11:12:10.123457
D.
+00-300 , +00-650, +00 11:12:10.123457
Could someone explain why this, please!
INTERVAL ’300′ MONTH it is something like INTERVAL YEAR TO MONTH:
300 months is 25 years. It cannot be +00-300 because when specifying a trailing field it must be less significant than the leading field. That is way we get result 25 years 00 months.
250 months is 20 years and 10 months:
select interval ‘250’ month from dual;
INTERVAL’250’MONTH
——————
20-10
The same for INTERVAL ’54-2′ YEAR TO MONTH. Cannot be 00-650 (which is 54*12 +2) but 54-02. It is the same reason – trailing field must be less significant than the leading field.
INTERVAL ’11:12:10.1234567′ HOUR TO SECOND
it in fact
INTERVAL’11:12:10.1234567’HOURTOSECOND
————————————–
0 11:12:10.123457000
select INTERVAL ’28:12:10.1234567′ HOUR TO SECOND FROM dual;
INTERVAL’28:12:10.1234567’HOURTOSECOND
————————————–
1 4:12:10.123457000
I don’t understand this part :/
“The same for INTERVAL ’54-2′ YEAR TO MONTH. Cannot be 00-650 (which is 54*12 +2) but 54-02. It is the same reason – trailing field must be less significant than the leading field.”
and this
NTERVAL ’11:12:10.1234567′ HOUR TO SECOND
it in fact
INTERVAL’11:12:10.1234567′HOURTOSECOND
————————————–
0 11:12:10.123457000
select INTERVAL ’28:12:10.1234567′ HOUR TO SECOND FROM dual;
INTERVAL’28:12:10.1234567′HOURTOSECOND
————————————–
1 4:12:10.123457000
28:12:10.1234567 HOUR TO SECOND goes like this :
28 hours = 24 hurs + 4 hours
= 1 day + 4 hours
= 1 4(H):12(M):10(S):1234567 (Msec.)
Thaks Justina, today I will give my exam.
A
could someone give a link to oracle documentation that treats time conversions in greater detail. Thanks.