If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > SQL Statement for look-up range of time by month

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-29-03, 12:46
NaomiC NaomiC is offline
Registered User
 
Join Date: Sep 2003
Location: Miami
Posts: 1
Angry 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
Reply With Quote
  #2 (permalink)  
Old 09-29-03, 18:34
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
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
Reply With Quote
  #3 (permalink)  
Old 10-01-03, 14:11
absent absent is offline
Registered User
 
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?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On