Sélectionner les loggings entre deux dates dans deux colonnes

Comment sélectionner les loggings entre deux dates dans deux colonnes?

Select * From MyTable Where 2009-09-25 is between ColumnDateFrom to ColumnDateTo 

J'ai une date (2009-09-25) et j'aime sélectionner les loggings qui sont dans la période ColumnDateFrom à ColumnDateTo.

Échantillon

Enregistrement 1 ColumnDateFrom = 2009-08-01 ET ColumnDateTo = 2009-10-01

Enregistrement 2 ColumnDateFrom = 2010-08-01 ET ColumnDateTo = 2010-10-01

Si ma date d'input est 2009-09-28; alors j'obtiens l'logging 1

Standard Entre devrait fonctionner (T-SQL).

 SELECT * FROM MyTable WHERE @MYDATE BETWEEN ColumnDateFrom AND ColumnDateFrom 

Essaye ça:

 SELECT * FROM MyTable WHERE '2009-09-25' BETWEEN ColumnDateFrom AND ColumnDateTo 

si je comprends bien, essayez ceci:

 SELECT * FROM MyTable WHERE ColumnDateFrom <= '2009-09-25' AND ColumnDateTo >= '2009-09-25' 
 select * from MyTable where ColumnDateFrom <= '2009-09-25' and ColumnDateTo >= '2009-09-25' 

mysql:

 select * from MyTable where '2009-09-25' between ColumnDateFrom and ColumnDateTo 

Retirez simplement le "Is"

 Select * From MyTable Where '2009-09-25' Between ColumnDateFrom to ColumnDateTo 

Souvenez-vous de considérer l'heure si les valeurs des colonnes contiennent la date et l'heure … (en supposant que DateOnly () est une fonction qui dépouille l'heure d'une colonne datetime)

 Select * From MyTable Where '2009-09-25' Between DateOnly(ColumnDateFrom) To DateOnly(ColumnDateTo)