PDA

View Full Version : New Items Displayed


twalter
09-15-2003, 11:50 PM
With this bit of code you can display the word "New" or even an Image beside any item posted within a certain number of days of the current date.

Example: You posted an item to your web app and for the next 14 days the word "New" will appear beside the posting. On the 15th day the word "New" will no longer display on that particular posting.

----------- Code Snippet ------------
dim countdays, datesubmitted, NowJulianDate, JulianDatesubmitted

'rs("DateSubmitted") is grabbed from the database and formatted and then converted to a julian date.
'here I hardcoded it for showing how it works.

'NowJulianDate is done the same way. First formatted and then converted to julian date.

countdays = 0

'datesubmitted = FormatDateTime(rs("DateSubmitted"))
datesubmitted = FormatDateTime("09/4/2006 09:00:00 AM")
NowJulianDate = (DatePart("y", Date()))
JulianDatesubmitted = DatePart("y", datesubmitted)
countdays = NowJulianDate - JulianDateSubmitted

if countdays <= 14 then

Response.write "New"
Else
Response.write "&nbsp; "

end if


----------- End Code Snippet ------------

View Demo (http://www.aspbasic.net/examples/new/new.asp)