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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Records by Certain Date

Status
Not open for further replies.

jmurrayhead

Programmer
Feb 13, 2004
47
US
Hello,

I have an Access database that has a column for an expiring date. How would I query the database to display only records whose expiring date is greater than the current date? For example, if the current date was 6/16/2004 and there were these expiring dates:
6/1/2004 6/15/2004 6/17/2004 6/18/2004

then only 6/17 and 6/18 would display.

Thanks
 
Code:
<%
myDate = Date()
strSql = "SELECT * FROM yourTable WHERE ExpiringDateColumn > #" & myDate & "#"
set conn = server.createobject("ADODB.Connection")
conn.open yourConnectionString
set rs = conn.execute(strSql)
If not rs.eof then
    'do stuff with your records here
End if
set rs = nothing
conn.close
set conn = nothing
%>
 
Okay, that's what I was doing wrong. I did everything except use #. Why do you suppose that is used?

Thanks
 
If you use Jet.OleDB driver then you need to use "#" if you go for ODBC Driver you would use "'".

________
George, M
Searches(faq333-4906),Carts(faq333-4911)
 
Forgot to mention one thing - that is valid only for Access database.

________
George, M
Searches(faq333-4906),Carts(faq333-4911)
 
Thanks for the info...I am using ODBC but the # works fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top