Question

Asked on 2010-08-10 at 14:47:53ID: 26791324

Today's Date Minus X Days

by: allanau20500

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. 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(…
  2. SQL (Oracle) date format to include 3 shifts
    Hello Experts, I am really in need of some assistance.. I need to modify the below code to pull data from 3 shifts (Shift 1 - 6:00A to 2:00P..Shift 2 2:00P to 10:00P.. Shift 3 10:00P to 6:00A) FYI Shift 3 would be using the next day. Right now it is pulling from a date range, so please help not sure how to do this …
  3. 15 minute increment
    Can you please help me convert this code to a 15 minute increment instead of an hour! TO_CHAR(TO_DATE(CASE WHEN TO_NUMBER(TO_CHAR(trans_tms, 'mi')) > 59 THEN TO_CHAR(TRUNC(trans_tms, 'hh') + 1 / 48, 'hh24:mi:ss') ELSE TO_CHAR(TRUNC(trans_tms, 'hh'), 'hh24:mi:ss') …
  4. Aggregate based on two date columns
    Experts, I have a table ordered by MEM_ID, ADM_DATE and structed like... MEM_ID ADM_DATE DIS_DATE ALL_AMT ---------------------------------------------------------- 123 6/3/10 6/5/10 5.25 123 6/6/10 …
  5. How do I select a date range in Microsoft SQL se…
    I a using this SQL statement. However I am getting dates from before 1st January 2009. SELECT VisitNo, CustomerID, SiteID, CallOutNo, visit_id, call_date, despatch_date, CASE WHEN despatch_date IS NULL THEN call_date ELSE despatch_date END AS DateOfCall, call_time, despatch_time, CASE WHEN despatch…

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

Posted on 2010-08-10 at 14:51:22ID: 34779242

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

Posted on 2010-08-10 at 14:53:01ID: 34779243

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

Posted on 2010-08-10 at 14:53:44ID: 34779244

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:

Posted on 2010-08-10 at 14:54:48ID: 34779245

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

Posted on 2010-08-10 at 14:55:24ID: 34779246

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

Posted on 2010-08-10 at 14:55:34ID: 34779247

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