| | |
ASP Date Help - If Then Else
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2005
Posts: 1
Reputation:
Solved Threads: 0
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!
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:
You may use Select Case to control the display.
You can then use datediff function to calculate the duration to the next gig:
ASP Syntax (Toggle Plain Text)
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.
Ecommerce-Web-Store.com Building Your e-Business.
•
•
Join Date: Jun 2005
Posts: 107
Reputation:
Solved Threads: 3
Also you need to observe how you use symbols in your code
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:
ASP Syntax (Toggle Plain Text)
<% if day(now)/month(now) = 17/6 then %>
and that's not really what you want to do.
It should by:
ASP Syntax (Toggle Plain Text)
<% 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.
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:
there is a more gracefull way i konw but this gives the possibility of more options
ASP Syntax (Toggle Plain Text)
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:
ASP Syntax (Toggle Plain Text)
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
![]() |
Similar Threads
- Want Date Format in dd/mm/yyyy in ASP.Net With C#. (C#)
- ASP Date Function (ASP)
- can i use mysql database with asp (ASP)
- create a weekly and monthly report (ASP)
Other Threads in the ASP Forum
- Previous Thread: How to remove decimal points from a price...
- Next Thread: Do I really need an sql server
| Thread Tools | Search this Thread |
Tag cloud for ASP
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection calendar changeable connection current database databaseconnection diagnostics dreamweaver excel fso html iis microsoft msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption server single specfic sqlserver sqlserverconnection toolkit web webserver windows7





