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

Databases and ASP 1

Status
Not open for further replies.

anastasia

Programmer
Dec 13, 2000
111
GB
I am trying to include an iF statement within a Database Connection. I can connect to a database run an SQL query and loop through the recordset and display the records on screen. However I am trying to also use an IF statement to compare a session variable called bookingdate to a field in the database called bookingdate. The IF statement will check to see if the date in the session variable is equal to a date in the database field and if so will inform the user. However it is the IF statement that generates an error. The session variable holds a value that the user submits through a form this is then assigned to the session variable.

Has anyone any ideas.

Thanks.
 
if you are getting a type comparison error, it's probably because you should explicitly cast the database value as a Date, and maybe the Session variables as well, depending on whether or not you stored them as Date datatypes.

the syntax to cast as a date is as follows

dim mydate
mydate = cdate(Session("bookingdate"))

good luck
 
Thanks for your reply vasah20, that code you gave was the missing link. I inserted the code and hey presto worked first time, well with that extra oiece of code anyway.

Thanks for your help ( you are superb) You get my vote.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top