【转】NEXT_DAY --OCP-047-86

NEXT_DAY

The NEXT_DAY function returns the date of the first instance of a particular day of the week that follows the specified date.

 

Syntax

Description of next_day.gif follows
Description of the illustration next_day.gif

Purpose

NEXT_DAY returns the date of the first weekday named by char that is later than the date date. The return type is always DATE, regardless of the datatype ofdate. The argument char must be a day of the week in the date language of your session, either the full name or the abbreviation. The minimum number of letters required is the number of letters in the abbreviated version. Any characters immediately following the valid abbreviation are ignored. The return value has the same hours, minutes, and seconds component as the argument date.

Examples

This example returns the date of the next Tuesday after February 2, 2001:

SELECT NEXT_DAY('02-FEB-2001','TUESDAY') "NEXT DAY"
     FROM DUAL;

NEXT DAY
-----------
06-FEB-2001

 

NEXT_DAY的第2个参数 char 可以是数字1-7,分别表示周日到周六

取1个月后的星期天:

next_day(add_months(sysdate,1),1)

 

可以查看日历,检验结果

 

 

86. View the Exhibit and examine the description of the EMPLOYEES table.
Evaluate the following SQL statement:
SELECT first_name, employee_id, NEXT_DAY(ADD_MONTHS(hire_date, 6),1)
"Review" FROM employees;
The query was written to retrieve the FIRST_NAME, EMPLOYEE_ID, and review
date for employees.The review date is the first Monday after the completion
of six months of the hiring. The NLS_TERRITORY parameter is set to AMERICA
in the session.Which statement is true regarding this query?
A. The query would execute to give the desired output.
B. The query would not execute because date functions cannot be nested.
C. The query would execute but the output would give review dates that are
Sundays.
D. The query would not execute because the NEXT_DAY function accepts a string
as argument.

 

Answer: C

posted @ 2013-01-06 14:38  Peyton  阅读(156)  评论(0编辑  收藏  举报