Solved

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

Posted on 2008-06-24
1
262 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Syntax 5 37
Query Syntax 17 34
TSQL query to generate xml 4 33
Separate 2 comma delimited columns into separate rows 2 31
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

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