I am building a product rental system and have the following 3 tables -
In the RRental Table the field "DateOut" represents the start date of the product rental period and "DateIn" is the return date. I have set the datatype of these fields as "datetime" in my database.
I am trying to retrieve all products that are not already booked out for a given set of dates.
I have created the following stored procedure
Create Procedure getRentalProductsAvailable --'22/04/2006', '26/04/2006'
Select * From RProduct
Inner Join RProductType ON RProduct.ProductTypeID = RProductType.ProductTypeID
Where RProduct.ProductID NOT IN(Select PR.ProductID From RProductRental PR
Inner Join RRental R ON PR.RentalID = R.RentalID
WHERE (@DateOut >= DateOut) And (@DateIn <= DateIn))
I seem to be getting errors on the date fields, i have tried using Cast and Convert and changed the datatypes but cant seem to run the procedure and get it to work.
Any help would be greatly appreciated.
Thanks in advance.