Remove hour in DateTime variable using SQL SERVER


When is using DateTime var and save date and hour, the problem is using filters of date only, example:

register1 01/01/2010 01:01:12
register2 02/01/2010 12:50

I run a filter that return all registers of december 2 to january 2 :

SELECT Register FROM Registers
WHERE dateRegister BETWEEN ‘02/12/2009’ AND ‘02/01/2010’

This return 1 register only, because the register 2 has date greater than the filter

The solution is to convert varchar to datetime:


SELECT Register

FROM Registers
WHERE CONVERT(DateTime,CONVERT(varchar, Fecha , 101),103)
BETWEEN ‘02/12/2009’ AND ‘02/01/2010’


it works!!