i have a database where daily sale is recorded. now i want to get the client outstanding between two dates. my date_ column is in varchar. i m not getting the required result.through this query and when i used between query its showing wrong data.so what is the solution? kindly help

SELECT clientid AS [ID],SUM(convert(float, total)) AS [SUM] 
       FROM buffalo_milk_sale 
       WHERE clientid BETWEEN 'HD001' AND 'HD099' 
       AND CONVERT(DateTime, date_, 103) >= CONVERT(DateTime, '01/09/2014', 103) 
       AND CONVERT(DateTime, date_, 103) <= CONVERT(DateTime, '09/09/2014', 103)
GROUP BY clientid

Error

The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

Related posts

Recent Viewed