Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Compare 1

Status
Not open for further replies.

coachdan

MIS
Mar 1, 2002
269
US
I am trying to come up with an idea on writing an effective script (ASP) to compare the date to another date hard-coded in and return the correct info. It is for a baseball teams website to list where each team is each day. My idea is to have it scroll across in a marquis if it's possible.

Here's my thought process:

varToday = Date() 'store todays date in variable

Select Case varToday

Case 03/30/05
Freshmen vrs. Ballard (A) 6:30
JV - idle
Varsity vrs. Ballard (H) 4:30

Case 03/31/05
Freshman vrs. Eastern (H) 4:30
JV vrs. Eastern (H) 7:00
Varsity vrs. Eastern (A) 4:30

End Select

I know there is more to it than that, but I am not sure how to proceed. Can it be done in a scrolling marquis? I am not using a db at this time - it will be hard-coded.

coachdan32
 
Bless that submit button. You can use the ASP page if you want, but it might be easier just to do the whole thing in VBScript or Javascript and HTML rather than worry about ASP. I believe the marquee's are Javascript so you already have that page. You can probably put your Select Case directly in the marquee page and skip the ASP altogether.
Just my 2 penny's worth.

Paul
 
I decided to abandon the scrolling marquis idea - I am going to add a table to do it in.

I have 3 columns that I am going to call the variables in (varVarsity, varJV, varFresh). I am using the following scenario to determine contents:

varDate = Date()

Select Case varDate
Case 3/28/05
varVarsity = "idle"
varJV = "Ballard (A) 7:00"
varFresh = "Ballard (A) 4:30"
End Select

This is just one instance of the select statement, there are many more dates. I have 2 main problems I could use advice on:

1. I am not sure what format the date will be coming in. Will it be an actual date? Or will it be a number? Does the select statement date need to be in quotes?

2. Somehow I need to put the Select inside a nested IF and I don't know how to handle this. I only hard-coded the dates between the start of the season and the end of the season. Before it enters the Select Statement I need to check the value and if it is before 3/28/05, I need to set all three variables to "idle". Also, if the value is greater than 5/20/05, I need to set all three variables to "idle". Any suggestions would be great?


coachdan32

 
If this is MS Access, then the Case date probably needs to be set inside # signs.
The rest would be something like this.
Code:
If Date() < #3/28/05#  Or Date() > #5/20/05# Then
    varVarsity = "idle"
    varJV = "idle"
    varFresh = "idle"
Else
Select Case varDate
        Case #3/28/05#
            varVarsity = "idle"
            varJV = "Ballard (A) 7:00"
            varFresh = "Ballard (A) 4:30"
End Select
End If

Paul
 
This for a web page - it is ASP/vbscript. It is not pulling anything from a database - all the dates are hard-coded in the mentioned Select Case format. I only listed one of the dates as an example.

coachdan32

 
Did you try it using the delimiters? I think even if it's hardcoded/VBScript, you will need the # sign because otherwise the script will try and perform division on the values. If the # sign doesn't work, then use single quotes ('3/28/05') but my bet is #.

Paul
 
Paul,

I tried it last night and it worked like a charm. I hard-coded a couple of dates in to see if it would pull the right info and it performed flawlessly. Thanks for the hand.

coachdan32

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top