Search between dates using two columns

Asked

Viewed 236 times

-3

What is wrong?

SELECT
    ID_Contrato_Reserva,
    DATE_FORMAT(STR_TO_DATE(data_ini,"%d/%m/%Y" ), "%Y/%m/%d") AS dataIni,
    DATE_FORMAT(STR_TO_DATE(data_Fim,"%d/%m/%Y" ), "%Y/%m/%d") AS dataFim
FROM 
    contrato_reserva

WHERE
    ( dataIni BETWEEN "2011/09/14" AND "2012/09/14" )
    AND
    ( dataFim BETWEEN "2011/09/17" AND "2012/09/17" )

Online http://sqlfiddle.com/#! 2/3827a5/54

1 answer

0

SELECT ID_Contrato_Reserva, DATE_FORMAT(STR_TO_DATE(data_ini,"%d/%m/%Y" ), "%Y/%m/%d") AS dataIni, DATE_FORMAT(STR_TO_DATE(data_Fim,"%d/%m/%Y" ), "%Y/%m/%d") AS dataFim 
FROM contrato_reserva 
WHERE ( dataIni BETWEEN "2011/09/14" AND "2012/09/17" ) 
AND ( dataFim BETWEEN "2011/09/14" AND "2012/09/17" )

Browser other questions tagged

You are not signed in. Login or sign up in order to post.