asp calendar / date checking

Results 1 to 2 of 2

Thread: asp calendar / date checking

  1. #1
    Join Date
    Dec 1969

    Default asp calendar / date checking

    I have adapted the calendar code taken from this 4GuysFromRolla link:<BR><BR>What I need to do is to set up the facility for a user to be able to browse through the calendar and to see which dates are taken, and which are not. <BR><BR>At the moment I have a form which takes a start date and an end date, and enters them into a database (stored in yyyy-mm-dd format in Date fields in Access). <BR><BR>I&#039;ve been trying to work out how to run the code to allow it to check each date as it loops through the days and months, and to check if it has been booked out. <BR><BR>say I have a range of fields in the database:<BR><BR>dfrom = 2002-08-10<BR>dto = 2002-08-25<BR><BR>dfrom = 2002-09-02<BR>dto = 2002-09-06<BR><BR>dfrom=2002-12-20<BR>dto=2002-12-30<BR><BR>At the moment I&#039;m feeling well out of my depth since I can envisage having to search the entire db for each month, and then for each month run a check with each calendar date to see if the same date is logged in the database. If it is I can flag it as being taken, if not it&#039;s available. <BR><BR>In a version based on the 4Guys code I compare each calendar date with each record in the database (which are stored as individual dates rather than date ranges as I&#039;m using above). If the dates match I can flag with a &#039;*&#039;. <BR><BR>This is the code I&#039;m using as I loop through the calendar, and check the db:<BR><BR> &#039;-- format current calendar date into yyyy-mm-dd --<BR><BR> loopDate = year(dDate) & "-" & Month(dDate) & "-" & iCurrent &#039;ICurrent = day of the month<BR><BR> &#039;-- open the table row --<BR><BR> If iPosition = 1 Then<BR> Response.Write(vbTab & "&#060;tr&#062;" & vbCrLf)<BR> End If<BR><BR> &#039;-- Write the date and subject --<BR><BR> Response.Write(vbTab & vbTab & "&#060;td valign=top bgcolor=#eeeeee&#062;" & iCurrent)<BR><BR> If Not opRS.BOF Then<BR> <BR> opRS.MoveFirst<BR> Do Until opRS.EOF<BR> <BR> eventDate = opRS("eventDate")<BR> <BR> if cDate(loopdate) = cDate(eventDate) then<BR> <BR> Response.Write("<BR>&#060;font color=red&#062;*&#060;/font&#062;<BR>")<BR> End If<BR><BR> opRS.MoveNext<BR> Loop<BR><BR> End If<BR><BR> Response.Write("&#060;/td&#062;" & vbCrLf)<BR><BR><BR>--------------------------<BR><BR>Any ideas greatly appreciated. <BR><BR>Thanks<BR><BR>Jim

  2. #2
    Join Date
    Dec 1969

    Default RE: asp calendar / date checking

    The idea of storing individual dates sounds much better than date ranges to me. If you have individual dates then you could do something like this:<BR><BR>1. Select all the dates from the DB for the month you are going to display<BR>2. As you write out the calender check each day to see if it&#039;s equal to a date in your recordset. If not write it as open and move to the next date. If it is taken write it as taken and movenext in your recordset before moving to the next date.<BR><BR>I&#039;m sure you could use this same pattern with the from/to date ranges, but the looping and sql statement would be a little trickier. Either way your first step should be to write a SQL statement that will return all the booked dates for a given month.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts