Solved

How can I query records that are only within the last year using sysdate?

Posted on 2008-06-24
1
260 Views
Last Modified: 2013-12-19
Hi There,

I have a field invoice_date that is a DATE field. I want to be able to select all rows from the table invoice  to show customers who have had an invoice within the last 12 months using sysdate. How can this be done?


Thassk,
R
0
Comment
Question by:Rhonda Carroll
1 Comment
 
LVL 73

Accepted Solution

by:
sdstuber earned 125 total points
ID: 21857168
select * from yourtable where invoice_date > add_months(sysdate,-12)

or

select * from yourtable where invoice_date > sysdate-365
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Export BLOB data from Oracle 10g 4 25
sql for Oracle views 8 37
SQL Help joining two tables 7 33
Access Date Query 28 29
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now