1

I just try this and I got a syntax error with tdate (it a DATE type)

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

is anyone can help me out..?? thanks!!!!

2 Answers 2

1

I do not think you need to bother casting either field since you should be able to extract the month directly from both. I would try:

select * 
from treatment 
where extract(month from tdate) = extract(month from current_date)
Sign up to request clarification or add additional context in comments.

Comments

1

Is this what you're looking for instead:

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

It should be cast(field as type) where you have cast(date as type).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.