Home > ASP Development > Overflow error on date: '27/11/2005'

Overflow error on date: '27/11/2005'



Hi,



I am developing a calendar webpage that displays 14 months from the current date. I keep getting this error while trying to view the page and I'm guessing that its down to too much info needing to be processed. Can anyone help? Heres my code:




Code:


<TABLE COLS="7" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<%

Response.Write "<td></td>"
For iweek = 1 to 5
For DayLoop = 1 to 7

Response.Write "<td bgcolor='Yellow'>" & WeekDayName(Dayloop, True, 0)& "</td>"
Weekname = Weekname + 1

Next
Next
Weekname = Weekname + 1
Response.Write "<td bgcolor='Yellow'>Mon</td>"
Response.Write "<td></td>"
Response.Write "</TR>"

For iMonth = 1 to 14

dtToday = Date()
CurrentMonth = Dateadd("m",count, dtToday)
'Gets the year based on the variable TheDate
CurrentYear = Year(dtToday)

'This is used to get the month name for TheDate
CurrentMonthName = MonthName(datepart("m", CurrentMonth))

'DateSerial will format the year, month and date and return it in date format.
FirstDayDate = DateSerial(TheYear, CurrentMonth, 1)


FirstDay = WeekDay(FirstDayDate, 0)

CurrentDay = FirstDayDate



Response.Write "<TR>"
Response.Write "<td>" & left(CurrentMonthName, 3) & right(CurrentYear, 2) & "</td>"

If FirstDay <> 1 Then
Response.Write "<TD Colspan='" & FirstDay -1 & "' BGCOLOR='lightgreen'>"
End if

DayCounter = FirstDay



CorrectMonth = True

Do While CorrectMonth = True

If CurrentDay = CurrentMonth Then
Response.Write "<TD align='Center' Bgcolor='red'>"
Else
Response.Write "<TD align='Center' BGCOLOR='lightblue'>"
End if

Response.Write Day(CurrentDay) & "</td>"

DayCounter = DayCounter + 1

If DayCounter > 31 then
Response.Write "<TD BGCOLOR='lightgreen'></td>"

Response.Write "</TR><TR>"

End if

CurrentDay = DateAdd("d", 1, CurrentDay)
Week = Week + 1

If Month(CurrentDay) <> CurrentMonth then
CorrectMonth = False
End if
count = count + 1
Loop
Next
%>

</TR>
</TABLE>






thanks



holmags

    
Guest


The variable CurrentMonth holds a full date (27/11/2005) that's today
replacing the dateserial line with this


Code:


	'CurrentMonth is actually a full date
	FirstDayDate = dateAdd("d", (datePart("d", CurrentMonth) * -1) + 1, CurrentMonth)




should help.

I'll let you have a go at working it out

Was this answer helpful ? Yes No   
Guest


Thanks for replying. That solved my problem but the dates are only displaying the first for each month. They are all in the right place in terms of the days of the week tho so thats a start.





Thanks for your help



holmags

Was this answer helpful ? Yes No   
Guest


I've got it all working now I'm just having a few problems with getting certain dates to have a different colour if they are booked. I've got it linked up to an access db but don't know which way to go about it. Would I need to create some sort of array so that all the dates in between the TO and From dates are coloured in or some sort of datediff count. This is what I've got so far:






Code:


		Booked = RS("Date_From")

if CurrentDay = Booked then
Response.Write "<TD align='Center' class='days2'>"
Response.Write Day(CurrentDay) & "</td>"
Else
Response.Write "<TD align='Center' class='days'>"
Response.Write Day(CurrentDay) & "</td>"
end if






All this does is one date at the moment. Any help or links to tutorials would be great.



thanks



holmags

Was this answer helpful ? Yes No   
Guest


How are your booked days stored in your table? It appears you might want to store them as comma seperated values.



Then, you'll need to Split() them into an array and Loop to see if any array value matches the current date.



If you need any help, just let me know.

Was this answer helpful ? Yes No   
Guest


Do you have a date_from and a date_to?

If so you could try doing a datediff on them and looping that
many times

Was this answer helpful ? Yes No   
Guest


Thanks for replying. The two fields from the db are date_To and Date_From . I've started doing the datediff bit of code and this is what I've got so far:




Code:



DateFrom = RS("Date_From")

Do While CorrectMonth = True

ColourBy = Datediff("d",RS("Date_From"),RS("Date_To"))

if diff < ColourBy then

Booked = Dateadd("d",diff, DateFrom)
Else
BookedDays = False
end if


if CurrentDay = Booked then
BookedDays = True
Response.Write "<TD align='Center' class='days2'>"
Response.Write Day(CurrentDay) & "</td>"
Elseif BookedDays = True then
Response.Write "<TD align='Center' class='days2'>"
Response.Write Day(CurrentDay) & "</td>"
Else
Response.Write "<TD align='Center' class='days'>"
Response.Write Day(CurrentDay) & "</td>"
end if








I've created a counter called diff which isn't in the code above which is used to only colour the difference between the 2 dates, e.g 7 days. The bit of code I put in above is a bit buggy at the moment and I'm not sure if thats the right way to go about it. Any help would be appreciated



thanks



holmags

Was this answer helpful ? Yes No   
Guest


I've found a bit of a solution to my prob. I've modified the code slightly and it works for one month. I now need to put in a RS.movenext loop and it will hopefully be ok. Heres the code:




Code:


	Do While CorrectMonth = True
DateFrom = RS("Date_From")
ColourBy = Datediff("d",RS("Date_From"),RS("Date_To"))

if diff <= ColourBy then

Booked = Dateadd("d",diff, DateFrom)
Else
BookedDays = False
end if


if CurrentDay = Booked then
BookedDays = True
Response.Write "<TD align='Center' class='days2'>"
Response.Write Day(CurrentDay) & "</td>"
Elseif BookedDays = True And CurrentDay <> RS("Date_To") then

Response.Write "<TD align='Center' class='days2'>"
Response.Write Day(CurrentDay) & "</td>"
Else
Response.Write "<TD align='Center' class='days'>"
Response.Write Day(CurrentDay) & "</td>"
BookedDays = False
end if








thanks for your help



holmags

Was this answer helpful ? Yes No   
Guest


Hi baseballdue,



Thats an interesting suggestion. Would that be hard to do? I've got some sort of solution at the moment but that may be a better one. The dates are stored in this format 11/11/2005





regards



holmags





thanks for your help elijathegold

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved