NEXT_DAY() function returns the date of the first weekday specified by day name that is later than a date.
The following shows the syntax of the syntax of the
NEXT_DAY() function accepts two arguments:
DATE value or an expression that evaluates to a
DATE value which is used to find the next weekday.
is the day of week that you want to return.
weekday can be full name e.g.,
Tuesday or abbreviation e.g.,
Tue. In addition, the language of the
weekday must be in the language of your session.
In English, the weekday accepts the following values:
|SUNDAY||SUN||The first Sunday later than a date|
|MONDAY||MON||The first Monday later than a date|
|TUESDAY||TUE||The first Tuesday later than a date|
|WEDNESDAY||WED||The first Wednesday later than a date|
|THURSDAY||THUR||The first Thursday later than a date|
|FRIDAY||FRI||The first Friday later than a date|
|SATURDAY||SAT||The first Saturday later than a date|
NEXT_DAY() function always returns a
DATE value that represents the next weekday after the date.
The result date has the same hours, minutes, and second as the input date.
A) Get the next weekday later than a date
This example returns the date of the next Sunday after January 1, 2000:
SELECT NEXT_DAY( DATE '2000-01-01', 'SUNDAY' ) FROM dual;
It returns the following output:
B) Get the next working day for employees
See the following
employees table in the sample database:
The following statement gets next working days days which are later than the hire dates for the employees:
SELECT first_name, last_name, hire_date, NEXT_DAY( hire_date, 'Monday' ) NEXT_MONDAY FROM employees ORDER BY hire_date DESC;
The following illustrates the output:
In this example, the next working day of an employee is the next Monday after the hire date.
In this tutorial, you have learned how to use the Oracle
NEXT_DAY() function to get the date of the next weekday which is later than a specified date.