87. You want to display the date for the first Mon day 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.
Answer: A
答案解析:
参考:http://blog.csdn.net/rlhua/article/details/12848395
http://blog.csdn.net/rlhua/article/details/12832885
题意要输出下个月第一个星期一。
实验验证:
下个月的星期一是4号。由结果得知可以正确执行,并且结果是正确的。
scott@TEST0924> SELECT TO_CHAR(NEXT_DAY(LAST_DAY(SYSDATE),'MON'),
2 'dd "is the first Monday for" fmmonth rrrr')
3 from dual;
TO_CHAR(NEXT_DAY(LAST_DAY(SYSDATE),'MON'),'DD"ISTHEFIRSTMONDAYFOR"FM
--------------------------------------------------------------------
04 is the first Monday for november 2013
scott@TEST0924> select sysdate from dual;
SYSDATE
------------------
18-OCT-13
scott@TEST0924> select LAST_DAY(SYSDATE) from dual;
LAST_DAY(SYSDATE)
------------------
31-OCT-13
NEXT_DAY(LAST_DAY(SYSDATE),输出指定日期的下一个日期,指定的日期是星期一,即是11月4号。
scott@TEST0924> SELECT NEXT_DAY(LAST_DAY(SYSDATE),'MON') FROM DUAL;
NEXT_DAY(LAST_DAY(
------------------
04-NOV-13
最后以特定的格式输出。