Question

Today's Date Minus X Days

Rating9.1Excellent

Hi Experts!

say you pass a string parameter to your sproc that tells you how
many days to search in your table from today's date.
(unfortunately it's a string: ie: "1" or "2" or "10")

Say today's date is: 08-10-2010

If in the sproc you have:

And if you pass "1" your sproc should run like this:

SELECT *
FROM TBL01
WHERE rundate >= to_date(''2010-08-09'', ''YYYY-MM-DD'')
AND rundate  < to_date(''2010-08-10'', ''YYYY-MM-DD'')

And if you pass "2" your sproc should run like this:

SELECT *
FROM TBL01
WHERE rundate >= to_date(''2010-08-08'', ''YYYY-MM-DD'')
AND rundate  < to_date(''2010-08-10'', ''YYYY-MM-DD'')

So, what would the syntax look like if you pass 'x'?

SELECT *
FROM TBL01
WHERE rundate >= ???
AND rundate  < ???

TIA!

  1. Oracle PL/SQL date strings
    I am trying to get a 201006 (YYYYMM) and a 06-01-2010 (DDMMYYY) using Oracle PL/SQL syntax and I'm stuck. In Access I use, YrMnth: CLng(Format([ROW_ADDED_DTTM],"yyyymm")) to get 201006 and use MnthStart: CDate(Format([ROW_ADDED_DTTM],"mm-" & 1 &…
  2. return every month with value of sum(invoice_t…
    hi, I try to do a report by sql statement, but I found out that there no data if that month is no record I want with data return even if no data in this sql statement e.g. 10,11,12 of 2010 Thank you! Francis sZE select sum(invoice_total) , to_char(invoice_date, 'mm') from invoice where invoice_date between to_date('…
  3. SQL to find record on a particular date - not as …
    Hi I have a table similar to the following which tracks customers' movements between hotels. A CheckIn involves just that - one action - checking into a hotel on a "Date In". A Transfer involves two actions - checking out of one hotel and into another. Therefore a "Hotel In", "Hotel Out" and "Date In&q…
  4. to_char date problem
    I have the query in the code, could anyone please tell me what I am doing wrong?? I am trying to say that if a date is between 1 apr and 31 dec then show year + 1 else show year... for example 15-Oct 2010 should give answer 2011 and 15-Feb-2011 should give 2011
  5. Update effective hire date depending if the actual…
    I have a column which has the hire date of an employee and is of type date. I want to create a new column called effective hire date. The effective hire date is either the first day of the month the employee was hired or the first day of the next month depending on whether the employee was hired before or after the 15th day of the month. For example if an …

Solution

Sign up now to view this solution! It's quick, easy, and secure to subscribe. We will return you to this solution, unlocked, when you’re done.

About this Solution
View This Solution - Start Your 30 Day Free Trial
Zone
PL / SQL
Tags
Participating Experts
1
Solution Grade
A

Replies

 
by: cyberkiwi

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 
by: cyberkiwi

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 
by: allanau20

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 
by:

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 
by: cyberkiwi

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 
by: allanau20

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

Stay Connected

Oracle Around the Web

The latest Oracle news, tips, and tricks

Oracle Unveils Netra SPARC T3 Servers

New Carrier-Grade Blade and Rackmount Servers Deliver Better Performance, Density and Power Efficiency for the Communications Industry ...

read more

Oracle fixes 21 flaws in Java SE, Java for Business

Oracle is fixing 21 flaws in its Java SE and Java for Business products in its February critical patch update issued this week ...

read more

Obama’s Silicon Valley “Tech Supper”

Why was he there? Who wasn’t invited and why? What did they talk about? Why was he really there? These are the questions being debated ...

read more

Featured Oracle Experts

slightwv

slightwv has answered more than 2,000 Oracle questions and oversees database management within the U.S. Government. Slightwv

sdstuber

A regular presenter at the Collaborate conference, Oracle developer sdstuber is a top expert in PL/SQL and Oracle 9, 10 and 11. sdstuber

Testimonials

What users are saying about our experts

"The Oracle gurus provide answers, solutions and valuable workarounds"

User: schwertner

"Wow! Excellent, valuable explanation. Hats off to you"

User: aseshu70

"Solution worked fantastic and performs excellent! Thanks heaps"

User: klausbrandlhuber

Top Experts

  1. slightwv

    2,000

    0 points yesterday

    Profile

BrowseBecome an Expert