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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Request.QueryString Date Problem

Status
Not open for further replies.

RussOSU

Technical User
Apr 16, 2001
93
US
I am trying to create a website that is connected to a database. In the database I am storing information about up coming events. On my webpage I have inserted a calendar from


I have made a couple of small modification to the calendar such as color and size to better fit my webpage. Where I am running into my problem is that I want the page to display (in a main body table cell) the events for the date which was selected. If no date was selected then I want the page to open with the current date being chosen. The problem I am having is figuring out how to query the date which is chosen.

Currently the code sends the date to the query in the following format


I have set up my database to be able to query by specific months also. Inorder to do this I created each month day year as seperate fields. This is where I am running into my problem. Does anyone know how I can break apart the URL String so that I can query it in my SQL

Currently I have am trying the following:

strSQL4 = "Select * From Event where Month =" & Request.QueryString("month") & "-" & "And Day=" & Request.QueryString("day") & "-" & "And Year=" & Request.QueryString("year")

I am not sure if this is even the proper approach. Any help would be greatly appreciated. Thanks

Russ
 
Goto:
is that the calendar you are talking about? If so, you can download my edited version from the link there. I ran into the same (or similar) problem you are talking about right now and found the solution and incorporated it. Hope this works for you. (When you download it, it'll be in a zip with all the files includeing the access database.

If it's not the calendar you're using or would not work, perhaps you can desect the code to fix your problem. Otherwise you need to post code so we can see it. :)

-Ovatvvon :-Q
 
That is not the calendar that I was refering to. The problem that I have with that calendar is mainly the size that it takes up. The website in which I am using this calendar is


If you click on the project link it will take you to the page I currently am using the calendar on. This is just my development URL so that is why the page is posted and not working. If you go to the project page and click on one of the project links you will see an example of what I am basically trying to do with the calendar. The calendar is basically just a fancy way to post all the current month's days as links. I would like the information for each day to be posted the same way as the project links are in the main body. I am not sure how to do this however. The code for the calendar is very extensive and I am not sure posting it all would help. I am really a newbie to .asp and .vbs programming. Actually I am a newbie to all programming except for html which doesn't count.

The code for the calendar is at the link below


I have figured out the line of code to change the calendar to send the event date code to the querystring. However my problem after that is taking that date from the querystring and looking up the events that are to occur in the database. I hope this helps explain what I am trying to do. Thanks

Russ
 
If you know the line you are having the problem with then you should have the date you want, correct? When the user clicks on the date, you request it from the querystring and enter it into a variable on the asp page.

It looks like you have 3 seperate fields in your database to hold the date function for each event...if you want to do it that way, then you could probably do somthing like this:

<%
Dim myDate, myDay, myMonth, myYear, strSQL4

myDate = Request.QueryString(&quot;day&quot;)
myDay = Day(myDate)
myMonth = Month(myDate)
myYear = Year(myDate)

strSQL4 = &quot;SELECT * FROM Event WHERE ((([Event].[Month])='&quot; & myMonth & &quot;') And (([Event].[Day])='&quot; & myDay & &quot;') And (([Event].[Year])='&quot; & myYear & &quot;'));&quot;
%>

Assuming you have the three fields named &quot;month&quot;, &quot;day&quot;, and &quot;year&quot; in the &quot;event&quot; table.

That should work if it's a problem with your sql statement. Try that.




-Ovatvvon :-Q
 
Yeah - as Ovatvvon said; you're referencing querystring items that don't exists. You're attempting to use
Code:
querystring.month
and
Code:
querystring.year
when the only item in the querystring is
Code:
day
.

This is where your problem lies. Split the date before query your database, or if you have entire dates in the database and not just day, month & year, do a straight comparisson. Can be very buggy, so maybe use something like;
Code:
select * from events where month(eventDate)=&quot; & month(request.querystring(&quot;day&quot;)) & &quot; and day(eventDate)=&quot; & day(request.querystring(&quot;day&quot;)) . . .etc . . 

:o)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top