Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
SELECT * 
FROM 
    tblPickupDetails 
WHERE 
    (Recivedtime 
     BETWEEN 
         '" + FromDate + "00:00:00.000" + "'  AND '" + Todate + "23:59:59.999"+ "')

I need to write this query in correct way ?

I think following statement is wrong.
SQL
(Recivedtime 
 BETWEEN 
     '" + FromDate + "00:00:00.000" + "'  AND '" + Todate + "23:59:59.999"+ "')
Posted
v4

1 solution

I think this between query is correct.
I wonder if following query help

SQL
SELECT * 
FROM tblPickupDetails 
WHERE 
CONVERT(VARCHAR(10) ,Recivedtime ,101) >= CONVERT(VARCHAR(10) ,@FromDate,101)
CONVERT(VARCHAR(10) ,Recivedtime ,101) <= CONVERT(VARCHAR(10) ,@ToDate,101)


-Milind
 
Share this answer
 
v2
Comments
Hasiya 7-Nov-12 1:17am    
problem is Recivedtime data type is Datetime..i want to pass parametrer @FromDate and @Todate


SELECT *
FROM tblPickupDetails
WHERE
Recivedtime >= @FromDate
AND Recivedtime <= @Todate queary not working i try eliyer..
MT_ 7-Nov-12 1:21am    
Check the updated solution if that helps.
Hasiya 7-Nov-12 1:46am    
tnx for ur help.....-Milind

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