Skip to main content
← PL/SQL Topics

String & Data Functions

Explain date arithmetic: ADD_MONTHS, MONTHS_BETWEEN, LAST_DAY and NEXT_DAY

Date Arithmetic Functions

ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated

Adding a number to a DATE adds days; the dedicated functions handle months, month-ends and weekdays correctly.

How it works

DATE + n adds n days (and fractions of a day for hours). ADD_MONTHS(d, n) shifts by whole months and snaps to month-end when the source day does not exist in the target month. MONTHS_BETWEEN(d1, d2) returns the (possibly fractional) month gap. LAST_DAY(d) returns the last day of d's month. NEXT_DAY(d, 'MONDAY') returns the first named weekday after d.

How it works
SELECT SYSDATE + 7                              AS in_a_week,
       ADD_MONTHS(DATE '2026-01-31', 1)         AS end_of_feb,
       MONTHS_BETWEEN(DATE '2026-08-27',
                      DATE '2026-01-27')        AS months_gap,
       LAST_DAY(SYSDATE)                        AS month_end,
       NEXT_DAY(SYSDATE, 'MONDAY')              AS next_monday
  FROM dual;

Related questions

GroundingGenerated

Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.

Have a follow-up, or a different question?

Continue in Ask Oracle AI