?
Solved

Subtracting 1 month from a given date

Posted on 2008-09-29
2
Medium Priority
?
1,177 Views
Last Modified: 2013-12-07
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
Comment
Question by:nicoleheritage
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 22600249
this should do:
SELECT ADD_MONTHS(your_date, -1) FROM yourtable

Open in new window

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22600257
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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question