Oracle SQL - NEXT_DAY and LAST_DAY

Introduction

The following code shows how to use the date functions NEXT_DAY, LAST_DAY, ROUND, and TRUNC.

Compare the various function results with the first column, showing the current SYSDATE value.

Demo

SQL>
SQL> select sysdate
  2  ,      next_day(sysdate,'SAT') as next_sat
  3  ,      last_day(sysdate)       as last_day
  4  ,      round(sysdate,'YY')     as round_yy
  5  ,      trunc(sysdate,'CC')     as trunc_cc
  6  from   dual;

SYSDATE   | NEXT_SAT  | LAST_DAY  | ROUND_YY  | TRUNC_CC
--------- | --------- | --------- | --------- | ---------
14-APR-18 | 21-APR-18 | 30-APR-18 | 01-JAN-18 | 01-JAN-01

SQL>--   ww w  .j a  v a 2  s .com

Related Topic