Solved

Subtracting 1 month from a given date

Posted on 2008-09-29
2
1,164 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
  • 2
2 Comments
 
LVL 143

Accepted Solution

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

726 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