2014-11-18 2 views
0

에 캐스팅 할 때 난 그냥이 시도하고 내가구문 오류 추출물

select * 
from treatment 
where EXTRACT(month FROM cast (date as TIMESTAMP) tdate) = EXTRACT(month FROM cast (date as TIMESTAMP) current_date) 

이 사람이 나를 도울 수있다 있는데, TDate (그것을 DATE 타입)와 구문 오류가 발생했습니다 .. ?? 덕분에 !!!!

답변

0

두 필드 모두에서 직접 월을 추출 할 수 있어야하므로 필드를 캐스팅해야한다고 생각하지 않습니다. 나는 시도 할 것이다 :

select * 
from treatment 
where extract(month from tdate) = extract(month from current_date) 
+0

대단히 감사합니다 !!! :) –

0

는 대신 무엇을 찾고 있는지 이것이다 : 당신이 cast(date as type)이 곳

select * 
from treatment 
where EXTRACT(month FROM cast (tdate as TIMESTAMP)) = 
     EXTRACT(month FROM cast (current_date as TIMESTAMP)) 

그것은 cast(field as type)을해야합니다.

+0

대단히 감사합니다 !!! :) –