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

compare dates in asp

Status
Not open for further replies.

olegflute

Technical User
Sep 10, 2003
11
AU
How can I compare dates ? For example, I want to delete item IDs that have dates before or equal the current date, i.e
if rs(&quot;Date&quot;) <= Date then
rs.Delete

What is the correct code(condition) to compare dates?
 
You could actually handle this in a seperate SQL statement so that you would not have to loop through all of the records yourself doing the date check. Something like:
Code:
sqlStr = &quot;DELETE FROM TableName WHERE DateFieldName <= '&quot; & FormatDateTime(Now,2) & &quot;'&quot;

Then you could just execute this with an open connection. The advantage of moving this to the database to do the work is that it is going to handle the deletions faster than doing them one record at a time directly in your ASP script.

-Tarwn

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top