I run a band website and I want to display the next gig automatically.
For example

i want it to say "next gig - 17th june..." when the 17th june passes it will change to say "next gig - 20th june..."

I have never used ASP before and have only tried looking at some tutorial sites. This is what I have come up with very quickly.

<% if day(now)/month(now) = 17/6 then %>
Today
<% end if
day(now)/month(now) <= 17/6) then %>
17th June
<% end if
day(now)/month(now) >= 17/6) then %>
20th June
<% end if %>

I've put this in an HTML style document and saved it as ASP and uploaded it. Although the file is on the server when I try to view it I get a "The page cannot be displayed" message.

Could someone please let me know why Im getting this message, and tell me about any errors in the above code.

Many Thanks!

I would suggest you use database (MS Access is the easiest for small data size) to run the application. See www.haneng.com for tutorials.

You can then use datediff function to calculate the duration to the next gig:

TodayDate = Date()
' Query from database
...
...
DateJoin = RS("GigDate")

' Do the calculation
Diff = DateDiff("d", DateJoin, TodayDate) 

If Diff = 0 Then .... End If
If Diff > 0 Then .... End If

You may use Select Case to control the display.

Also you need to observe how you use symbols in your code

<% if day(now)/month(now) = 17/6 then %>

actually means: "if day(now) divided by month(now) = 17 divided by 6 then"
and that's not really what you want to do.

It should by:

<% if day(now) & "/" & month(now) = "17/6" then %>

use a database it will be easier then run a sql command that orders the dates ASC (asending) while database date not smaller than current date.

SELECT Table1.ID,Table1.gigdate, IIf([Table1]![gigdate]>Date(),[gigdate],IIf([Table1]![gigdate]=Date(),"Today","past")) AS gig
FROM Table1
ORDER BY Table1.gigdate ASC

it returns a past if it is over (incase you need to list your past dates you can just make a recordset that lists all the dates that gig is "past")

for you upcoming events you could edit it to be like:

SELECT Table1.ID,Table1.gigdate, IIf([Table1]![gigdate]>Date(),[gigdate],IIf([Table1]![gigdate]=Date(),"Today","past")) AS gig
FROM Table1
WHERE IIf([Table1]![gigdate]>Date(),[gigdate],IIf([Table1]![gigdate]=Date(),"Today","past"))  <> "past"
ORDER BY Table1.gigdate ASC

there is a more gracefull way i konw but this gives the possibility of more options

Thats for an access query. The sql in the asp page would be a bit different though

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.