Click here to Skip to main content
15,891,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
i am new in SQL can some one assist me to solve this problem???
i am passing two parameters to my SP using openquery ,but parameters not allowed.get error like Conversion failed when converting date and/or time from character string.
how to correct this?????

Below is my Query
parameters are
SQL
@Fromdate varchar(10),
@Todate varchar(10)
SQL
SELECT * into #TblPlatinumDate
FROM  OPENQUERY([MUMFRDBSACT], 'SELECT Distinct(Passenger_Pri_MobileNo) as     MobileNo ,COUNT(*)as TripCount
from  [E2e_Tabcab].[dbo].[FR_TRANS_Booking] a (nolock)
where  IsCancel = ''0'' and Convert(DATE,PickupDateTime,105) 
BETWEEN ''+@Fromdate+'' and ''+@Todate+'' 
GROUP BY Passenger_Pri_MobileNo,IsCancel
having count(IsCancel)>= ''46''')
Posted
Updated 8-May-15 2:17am
v3
Comments
CHill60 8-May-15 8:18am    
Looks like PickupDateTime is being stored as a char instead of a DateTime. Examine your data - does it really look like a date and are there any nulls?
And why pass Dates as varchar(10)? Use DateTime or Date

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900