# PL/SQL Questions and Answers – PL/SQL Date and Time

This set of PL/SQL Multiple Choice Questions & Answers (MCQs) focuses on “PL/SQL Date and Time”.

1. How many classes of date and time related data types are present in PL/SQL?
a) 2
b) 4
c) 5
d) 3

Explanation: There are two classes of date and time related data types that are present in PL/SQL. They are – Datetime datatypes and Interval datatypes. Each of these classes has different datatypes within them.

2. Which of the following datatypes is not part of the Datetime datatypes class?
a) TIMESTAMP
b) DATE
c) TIMESTAMP WITH TIMEZONE
d) INTERVAL YEAR TO MONTH

Explanation: The datatype which is not part of the datetime datatype class is INTERVAL YEAR TO MONTH. This datatype belongs to the Interval datatypes class. The other datatype which is part of the Interval class is INTERVAL DAY TO SECOND.

3. How many datatypes are present within the Datetime datatype class?
a) 2
b) 3
c) 4
d) 5

Explanation: The datetime datatype class contains 4 different datatypes. These are – DATE, TIMESTAMP, TIMESTAMP WITH TIMEZONE and TIMESTAMP WITH LOCAL TIMEZONE. Each of these datatypes have their different functions.

4. What is the valid datetime value for theHOUR field in the datetime datatypes?
a) 01 to 24
b) 00 to 23
c) 00 to 11
d) 01 to 12

Explanation: The datetime data types consist of fields. The values of these fields determine the value of the data type. The valid datetime value for the HOUR field in the datetime datatypes is 00 to 23.

5. Which of the following datetime datatype includes a time-zone region name in its value?
a) DATE
b) TIMESTAMP
c) TIMESTAMP WITH TIMEZONE
d) TIMESTAMP WITH LOCAL TIMEZONE

Explanation: TIMESTAMP WITH TIME ZONE is a variant of TIMESTAMP that includes a time zone region name or a time zone offset in its value. The time zone offset is the difference (in hours and minutes) between local time and UTC.

6. Which of the followingdatetime function is used to return the time value from a time zone specified by the user?
a) SYSDATE ()
b) ROUND ()
c) NEXT_DAY ()
d) NEW_TIME

Explanation: The NEW_TIME function is used to return the time or day value from a time zone specified by the user. SYSDATE () is sued to return the current date time of the system. NEXT_DAY (x, day) is used to Returns the datetime of the next day after x.ROUND (x, [unit]) is used to round off x.

7. Which of the following interval function is used to convert a number x to an INTERVAL YEAR TO MONTH?
a) NUMTODSINTERVAL(x, interval_unit);
b) NUMTOYMINTERVAL(x, interval_unit);
c) TO_DSINTERVAL(x);
d) TO_YMINTERVAL(x);

Explanation: The function NUMTOYMINTERVAL(x, interval_unit); is used to convert a number x to an INTERVAL YEAR TO MONTH. NUMTODSINTERVAL(x, interval_unit); function is used to convert the number x to an INTERVAL DAY TO SECOND.TO_DSINTERVAL(x); function is used to convert the string x to an INTERVAL DAY TO SECOND. TO_YMINTERVAL(x); function is used to convert the string x to an INTERVAL YEAR TO MONTH.

Sanfoundry Global Education & Learning Series – PL/SQL.

To practice all areas of PL/SQL, here is complete set of 1000+ Multiple Choice Questions and Answers.