2012-12-11 2 views
1

나는 다음과 같은 쿼리가 :MySQL- 쿼리에서 날짜 - 시간을 잘라 내기

select * from player_source 
where source is not null 

ID  create_dtime 
001  2012-10-16 16:13:27 
002  2012-12-10 16:13:27 

및 결과 ...

나는를 필터링 할을 2012 년 12 월 3 일 이상 2012 년 12 월 9 일 이하의 create_dtime 결과 만 반환하도록 쿼리를 쿼리하십시오.

사용해 보았습니다.

select * from player_source 
where source is not null 
and Create_Dtime >= To_Date('2012-Dec-03','yyyy-mon-dd') 
and Create_Dtime <= To_Date('2012-Dec-09','yyyy-mon-dd') 

오라클 루트를 사용했지만 작동하지 않는 것 같습니다. 이견있는 사람?

+0

에 http : // dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_str-to-date –

답변

2

검색어 :

select * 
from player_source 
where source is not null 
and Create_Dtime >= '2012-10-03' 
and Create_Dtime <= '2012-10-09' 
0

시도이

select * 
from player_source 
where source is not null 
and Create_Dtime >= '2012-Dec-03' 
and Create_Dtime <= '2012-Dec-09' 
0

구문은 다음과 같습니다 또는 더 간결

select * from player_source 
where source is not null 
and Create_Dtime > '2012-12-03' 
and Create_Dtime <= '2012-12-09' 

:

select * from player_source 
where source is not null 
and Create_Dtime > '2012-12-03' BETWEEN 
and '2012-12-09'