I want to know how to achieve the following: I want to convert a varchar to a date format but so far I'm not very successfull...

My date (varchar) looks something like this: 02-02-2012 11:48 AM
And I want to convert it to the following this: dd-mm-yyyy

To be able to use the BETWEEN clause in the end.

I have the following script but it is not correct so any help regarding this will help me a lot!

SELECT Con_Consult_Date
FROM Consultation
WHERE CONVERT(varchar(30), Con_Consult_Date, 105) BETWEEN '01-01-2013' AND '31-12-2013'
GO

NVM people. I got the solution:

SELECT Con_Consult_Date
FROM Consultation
WHERE CAST(CONVERT(CHAR(10), CONVERT(DATETIME, Con_Consult_Date, 105), 101) AS DATE) 
BETWEEN CAST(CONVERT(CHAR(10), CONVERT(DATETIME, '01-01-2013', 105), 101) AS DATE) 
AND CAST(CONVERT(CHAR(10), CONVERT(DATETIME, '31-12-2013', 105), 101) AS DATE)
GO
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.