cust_main.paydate should be varchar(10), not @date_type ; problem reported