Take the Challenge!
Question 1
Oracle Database provides a function for returning the date of the last day of the month. It does not, however, provide a function for returning the date of the first day. Which of the following can be used to do this?- CREATE OR REPLACE FUNCTION plch_first_day (date_in IN DATE)
RETURN DATE
IS
BEGIN
RETURN TRUNC (date_in);
END;
/ - CREATE OR REPLACE FUNCTION plch_first_day (date_in IN DATE)
RETURN DATE
IS
BEGIN
RETURN TRUNC (date_in, 'MM');
END;
/ - CREATE OR REPLACE FUNCTION plch_first_day (date_in IN DATE)
RETURN DATE
IS
BEGIN
RETURN TRUNC (date_in, 'MONTH');
END;
/ - CREATE OR REPLACE FUNCTION plch_first_day (date_in IN DATE)
RETURN DATE
IS
BEGIN
RETURN TO_DATE (TO_CHAR (date_in, 'YYYY-MM')
|| '-01', 'YYYY-MM-DD');
END;
/
Given this declaration section:
DECLARE
c_format CONSTANT VARCHAR2 (22)
:= 'YYYY-MM-DD HH24:MI:SS' ;
l_new_year DATE
:= TO_DATE (
'2012-01-02 00:00:01'
, c_format);
which of the following blocks offers an exception section so that after that block is executed, the date and time 2012-01-01 00:00:01 will be displayed on the screen?
- BEGIN
DBMS_OUTPUT.put_line (
TO_CHAR (
l_new_year - 24
, c_format));
END; - BEGIN
DBMS_OUTPUT.put_line (
TO_CHAR (l_new_year - 1
, c_format));
END; - BEGIN
DBMS_OUTPUT.put_line (
TO_CHAR (
l_new_year
- 24 * 60 * 60
, c_format));
END; - BEGIN
DBMS_OUTPUT.put_line (
TO_CHAR (
TRUNC (l_new_year)
- 1
+ 1 / (24 * 60 * 60)
, c_format));
END;
No comments:
Post a Comment