You want to display the date for the first Monday of the next month and issue the following command:
SQL>SELECT TO_CHAR(NEXT_DAY(LAST_DAY(SYSDATE), ‘MON’), ‘dd “is the first Monday for ‘fmmonth
rrrr’) FROM DUAL;
What is the outcome?
A.
It executes successfully and returns the correct result.
B.
It executes successfully but does not return the correct result.
C.
It generates an error because TO_CHAR should be replaced with TO_DATE.
D.
It generates an error because rrrr should be replaced by rr in the format string.
E.
It generates an error because fm and double quotation marks should not be used in the format string.
Explanation:
• NEXT_DAY(date, ‘char’): Finds the date of the next specified day of the week (‘char’) following date. The value
of char may be a number representing a day or a character string.
• LAST_DAY(date): Finds the date of the last day of the month that contains date
The second innermost function is evaluated next. TO_CHAR(’28-OCT-2009′, ‘fmMonth’) converts the given
date based on the Month format mask and returns the character string October. The fm modifier trims trailing
blank spaces from the name of the month.
typo in the statement (single quote instead of missing 2nd double quote) but I guess A is still correct since the other answers seem false.
SELECT TO_CHAR(NEXT_DAY(LAST_DAY(SYSDATE), ‘MON’), ‘dd “is the first Monday for “fmmonth rrrr’) FROM DUAL;
Eric Sacramento
March 1, 2013 at 4:48 pm
SYSDATE = 01/03/2013 (DD/MM/YYYY)
First, it takes the last Monday of March – 25/03/2013 (LAST_DAY(SYSDATE))
And then, the next Monday of the year in this case 01/04/2013
SELECT TO_CHAR(NEXT_DAY(LAST_DAY(SYSDATE),’LUNDI’),’dd “is the first Monday for” fmmonth rrrr’)
FROM DUAL;
Result
01 is the first Monday for avril 2013
A
select sysdate from dual;
18-02-15
SELECT TO_CHAR(NEXT_DAY(LAST_DAY(SYSDATE), ‘MON’), ‘dd “is the first Monday for” fmmonth rrrr’) FROM DUAL;
It’s A as solution