Skip to main content
Jul 23, 2009 2:50 PM UTC
Question

No longer display record after a certain date has passed. ASP/SQL

How would I set a recordset to no longer display a record after a certain date has passed?

For example:
I have a list of classified adverts.


After a certain time period, say, 6 months, would it be possible to use some kind of SQL statement to no longer display the advert?

I'm using ASP - VBSCRIPT with an SQL server.


The the date field in the SQL database displays on the page like this 2009-07-23


Thanks
Gary

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

Lawrence_Cramer
Inspiring
Jul 23, 2009 4:57 PM UTC

Include this in your SQL statement

WHERE  dateExpire_field > Now()

This of course isn't the exact code, I'm not an ASP guy, but this is the concept. This way as long as the date you set your record to expire is "further out" than the current date the record will be pulled. Once the expire date has passed it wont

--
Lawrence   *Adobe Community Expert*
www.Cartweaver.com
Complete Shopping Cart Application for
Dreamweaver, available in ASP, PHP and CF
www.twitter.com/LawrenceCramer

Translate
Jul 23, 2009 6:27 PM UTC

Think I may have sussed it anyway (had to convert it slightly), used this statement:

WHERE Date >= cast(convert(varchar(8),getdate()-1,1) as datetime)

This now only displays the record whilst the date column in the table is either greater or equal to the current day

Translate