Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Location
    Miami
    Posts
    1

    Angry Unanswered: SQL Statement for look-up range of time by month

    Hello!

    I have been sucessful in finding a way to query using a specific date range but would LOVE to be able to find a way to query by a non date-specific time range.

    For instance:

    Selct all records that expire from today plus one month or expire today minus one month.

    I will be forever in awe and extremely thankful of who ever can help!

    Naomi

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Lightbulb

    In Oracle:

    Code:
    
    select * from MyTable
    where exp_date between sysdate and add_months(sysdate,1);
    
    Or
    
    select * from MyTable
    where exp_date between sysdate and add_months(sysdate,-1);
    
    Or
    
    select * from MyTable
    where exp_date between add_months(sysdate,-1)
    and add_months(sysdate,1);
    
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Oct 2003
    Location
    UK
    Posts
    5

    Red face Re: SQL Statement for look-up range of time by month

    Hey there...

    I think we have a similar problem... I'm trying to get SQL to return a query using user definable variables. sortta like something from a dropdown box.text to generate queries... But alas I can't find anything short of creating EACH and every query myself.

    Is there a way to go around the short way?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •