Home > ASP Development > Date function with variable problem.urgent

Date function with variable problem.urgent



Hi guys, i faced a problem that i need to make a date in varible and use date.add function to deal with it



below is my code,come someone tell me what the problem?



i = "11/30/2006"



<%=(DateAdd("d",7, i))%>



error message is

Expected statement

/1.asp, line 11

<%=(DateAdd("d",7, i))



ths a million

    
Guest


try this..


Code:



response.write((DateAdd("d",7, i)))



Was this answer helpful ? Yes No   
Guest


Quote:
Originally Posted by Guddu
try this..


Code:



response.write((DateAdd("d",7, i)))






brother i still got something have to ask u,can u look at code below?



if BookingType="Once" then



for i = TimeSlot to z



sql1 = "select * from RoomBooking where RoomType = '"&Room&"' and DateOfBooking = '"&BookDate&"' and TimeSlot = '"&i&"'"

set rt = conn.execute(sql1)



if rt.eof then

'sql="insert into RoomBooking (RoomType, DateOfBooking, Hours, Purpose, TimeSlot) values ('"&Room&"', '"&BookDate&"', '"Hours"', '"&Purpose&"', '"&i&"')"

sql = "Insert into RoomBooking (RoomType, DateOfBooking, Hours, Purpose, TimeSlot, MemberID) values ('"&Room&"', '"&BookDate&"', '"&Hours&"', '"&Purpose&"', '"&i&"', '"&session("MemberID")&"')"

conn.execute(sql)



else

end if

next



elseif BookingType="Daily" then

NewPeriod=DateAdd("d", 0, (EndTime))

response.write(NewPeriod)



for i = BookDate to NewPeriod



for i = TimeSlot to z



sql1 = "select * from RoomBooking where RoomType = '"&Room&"' and DateOfBooking = '"&BookDate&"' and TimeSlot = '"&i&"'"

set rt = conn.execute(sql1)



if rt.eof then

'sql="insert into RoomBooking (RoomType, DateOfBooking, Hours, Purpose, TimeSlot) values ('"&Room&"', '"&BookDate&"', '"Hours"', '"&Purpose&"', '"&i&"')"

sql = "Insert into RoomBooking (RoomType, DateOfBooking, Hours, Purpose, TimeSlot, MemberID) values ('"&Room&"', '"&BookDate&"', '"&Hours&"', '"&Purpose&"', '"&i&"', '"&session("MemberID")&"')"

conn.execute(sql)



else

end if

next



response.write(DateAdd("d", 1, (i)))

next



end if



my coding i suppose it can based on "once" and "daily" to perform insert statement,



but the error msg i got is



Invalid 'for' loop control variable

/WoodLandSec/AddBookingAct.asp, line 38, column 6

for i = TimeSlot to z



mind to pint out me how to solve teh error?thx a million

Was this answer helpful ? Yes No   
Guest


you are using the variable "TimeSlot" also a few line above. You have to reinitiate this variable, when you want to use it for a second forloop.

Was this answer helpful ? Yes No   
Guest


Quote:
Originally Posted by leuvenaar
you are using the variable "TimeSlot" also a few line above. You have to reinitiate this variable, when you want to use it for a second forloop.




this problem i solve alreaady, but i got another problem is actually my coding above suppose to work in i can choose to booking a room in timeslot based, and i can choose daily or one time only.i will do a for loop to insert various timeslot into database based on period(how many day to input(daily)) but what i got it just input a record into database.may i know what is my logic error?thx a million

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