Skip to Main Content
  • Questions
  • Subtracting months frorm a current date

Breadcrumb

May 4th

Question and Answer

Chris Saxon

Thanks for the question, Richard.

Asked: January 29, 2004 - 10:21 am UTC

Last updated: March 24, 2023 - 11:15 am UTC

Version: 8.1.7.3

Viewed 100K+ times! This question is

You Asked

I am trying to subtract 6 months from the current date (SYSDATE). I know about the ADD_MONTH function, but I haven't been able to find documentation about a "SUBTRACT_FUNCTION" which can do this for me.

and Tom said...



add_months( sysdate, -6 )


just add "minus six" months.

Rating

  (3 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Good and quick response

Richard, January 30, 2004 - 8:54 am UTC

Very quick response

A reader, January 09, 2019 - 1:55 pm UTC


Query to recursively print date with 13 month range backwards

Joe, March 24, 2023 - 4:12 am UTC

Can you please provide a query to print dates with 13 month difference recursively backwards. for Data migration for start_date and end_date range.

For example:

It should start from 01-DEC-2021 and print in reverse until 01-JAN-2000.

Start_date end_date
01-DEC-2021 11-JAN-2020
11-JAN-2020 12-NOV-2018
..
upto
01-JAN-2000




Thanks.
Chris Saxon
March 24, 2023 - 11:15 am UTC

You can use a method like:

select add_months ( start_date, -level ) from dual
connect by level <= ...

I discuss date generation in detail at:

https://blogs.oracle.com/sql/post/how-to-generate-days-weeks-or-months-between-two-dates-in-oracle-database