• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1195
  • Last Modified:

Subtracting 1 month from a given date

i have a date in mm/dd/yyyy format.
the date is always the end of the month.
for example 7/31/2007
i need to figure out what was the date at the end of the previous month ( i.e 06/30 2008). in mm/dd/yyyy format

what is the oracl sql for this ?
0
nicoleheritage
Asked:
nicoleheritage
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
this should do:
SELECT ADD_MONTHS(your_date, -1) FROM yourtable

Open in new window

0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
note: you should better use the 1st of the month, and use yourfield < 1st_of_month.
also, you should have the date in DATE date type, and not in VARCHAR2 data type...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now