ASP Date Help - If Then Else

Reply

Join Date: May 2005
Posts: 1
Reputation: tomraffe is an unknown quantity at this point 
Solved Threads: 0
tomraffe tomraffe is offline Offline
Newbie Poster

ASP Date Help - If Then Else

 
0
  #1
May 29th, 2005
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!
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: ASP Date Help - If Then Else

 
0
  #2
May 31st, 2005
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:

  1. TodayDate = Date()
  2. ' Query from database
  3. ...
  4. ...
  5. DateJoin = RS("GigDate")
  6.  
  7. ' Do the calculation
  8. Diff = DateDiff("d", DateJoin, TodayDate)
  9.  
  10. If Diff = 0 Then .... End If
  11. If Diff > 0 Then .... End If

You may use Select Case to control the display.
Ecommerce-Web-Store.com Building Your e-Business.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 107
Reputation: madmital is an unknown quantity at this point 
Solved Threads: 3
madmital madmital is offline Offline
Junior Poster

Re: ASP Date Help - If Then Else

 
0
  #3
Jun 1st, 2005
Also you need to observe how you use symbols in your code

  1. <% 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:

  1. <% if day(now) & "/" & month(now) = "17/6" then %>
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 131
Reputation: william_stam is an unknown quantity at this point 
Solved Threads: 2
william_stam's Avatar
william_stam william_stam is offline Offline
Junior Poster

Re: ASP Date Help - If Then Else

 
0
  #4
Jun 2nd, 2005
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.

  1. SELECT Table1.ID,Table1.gigdate, IIf([Table1]![gigdate]>Date(),[gigdate],IIf([Table1]![gigdate]=Date(),"Today","past")) AS gig
  2. FROM Table1
  3. 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:
  1. SELECT Table1.ID,Table1.gigdate, IIf([Table1]![gigdate]>Date(),[gigdate],IIf([Table1]![gigdate]=Date(),"Today","past")) AS gig
  2. FROM Table1
  3. WHERE IIf([Table1]![gigdate]>Date(),[gigdate],IIf([Table1]![gigdate]=Date(),"Today","past")) <> "past"
  4. ORDER BY Table1.gigdate ASC


there is a more gracefull way i konw but this gives the possibility of more options
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 131
Reputation: william_stam is an unknown quantity at this point 
Solved Threads: 2
william_stam's Avatar
william_stam william_stam is offline Offline
Junior Poster

Re: ASP Date Help - If Then Else

 
0
  #5
Jun 2nd, 2005
Thats for an access query. The sql in the asp page would be a bit different though
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for ASP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC