Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find records between two dates

Status
Not open for further replies.

manj

Programmer
Sep 22, 2000
28
GB
I have a query. I wish to select records that are between the current date and 1 month prior to the current date. How do I achieve this?

select col1, col2
from table
where date between currentdate and 1 month before current date

Any help will be appreciated.
[sig][/sig]
 
In Oracle:
Code:
SELECT col1, col2
FROM table
WHERE datefield > ADD_MONTHS(SYSDATE, -1) AND
      datefield < SYSDATE
Hope this helps...
[sig]<p>Terry M. Hoey<br><a href=mailto:th3856@txmail.sbc.com>th3856@txmail.sbc.com</a><br><a href= > </a><br>Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?[/sig]
 
Thanks Terry for the information,

I know sysdate retrieves the current date in Oracle but what about MS Access

Regards
manj [sig][/sig]
 
In Access, use the DATE function. Check it out in the help.

BTW, if you do not already subscribe to it, there is at least one Access specific newsgroup here.

Take Care,
[sig]<p>Terry M. Hoey<br><a href=mailto:th3856@txmail.sbc.com>th3856@txmail.sbc.com</a><br><a href= > </a><br>Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top