• Skip to primary navigation
  • Skip to main content

Tech Honey

The #1 Website for Oracle PL/SQL, OA Framework and HTML

  • Home
  • HTML
    • Tags in HTML
    • HTML Attributes
  • OA Framework
    • Item in OAF
    • Regions in OAF
    • General OAF Topics
  • Oracle
    • statement
    • function
    • clause
    • plsql
    • sql
You are here: Home / Oracle / function / Oracle/SQL NEXT_DAY Function

Oracle/SQL NEXT_DAY Function

November 2, 2012 by techhoneyadmin

Oracle SQL NEXT_DAY FunctionOracle NEXT_DAY Function is used to return the date of the next occurrence of the weekday from the date passed. SQL NEXT_DAY Function can be used with SQL SYSDATE,with other data types and SQL TO_CHAR Function.


Oracle NEXT_DAY Function Syntax

SELECT NEXT_DAY(date,weekday)
FROM table_name;

Here in the above Oracle NEXT_DAY Syntax

  • ‘date’ is the date that is passed to the NEXT_DAY function
  • ‘weekday’ is any day of the week (e.g. Monday, Tuesday, Wednesday, Thursday, Friday, Saturday or Sunday)

Oracle NEXT_DAY Function – Using SQL SYSDATE Example

Oracle NEXT_DAY Function can be used with SQL SYSDATE.

For example, the SQL NEXT_DAY Function query below returns the next occurrence of MONDAY from SYSDATE.

SELECT NEXT_DAY(SYSDATE,'MONDAY')
FROM DUAL;

Will return the date for next MONDAY e.g. “11/5/2012 2:40:59 PM”.
The next day’s date returned will depend upon the SYSDATE value of date.


Oracle NEXT_DAY Function – Using VARCHAR Example

Oracle NEXT_DAY Function can be used with other data types also.

For example, the SQL NEXT_DAY Function query below returns the nearest SUNDAY ahead from ’01-Jan-2012′

SELECT NEXT_DAY('01-Jan-2012','SUNDAY')
FROM DUAL;

Will return “1/8/2012” because the next SUNDAY from ’01-Jan-2012′ is January 8th, 2012.


Oracle NEXT_DAY Function – Using SQL TO_CHAR Example

Oracle NEXT_DAY Function can also be used with the SQL TO_CHAR Function to format the output.

For example, the SQL NEXT_DAY Function query below uses SQL TO_CHAR Function to format the output.

SELECT TO_CHAR(NEXT_DAY('01-Jan-2012','SUNDAY'),'DD-MON-YYYY')
FROM DUAL;

Will return “08-JAN-2012”.

Note the format of the output is different in example 2 and example 3.


Filed Under: function Tagged With: how to use next_day function in oracle database query, how to use next_day function in oracle plsql, how to use next_day function in oracle sql, NEXTDAYPLSQL, next_day function in oracle plsql, next_day function in oracle sql, syntax and example of next_day function in oracle database query, syntax and example of next_day function in oracle plsql, syntax and example of next_day function in oracle sql, using next_day function in oracle database query, using next_day function in oracle plsql, using next_day function in oracle sql

Copyright © 2023 · Parallax Pro on Genesis Framework · WordPress · Log in