Query of Records in DATE Fields by Month

Asked

Viewed 33 times

1

Hello! I would like a help I’m performing queries on a table VIAJEM where I own 2 fields IDA And CHEGADA. Both of the kind DATE. I need to consult all the records of a particular MES.

Ex. ida = '2016-08-15' chegada= '2016-09-01'. Although the arrival is in September the consultation should bring all the records of the month of August that are registered.

SELECT * FROM viajem WHERE Month(ida) = $mes or Month(chegada)=$mes;

I have to capture the variable via $post and then replace it in QUERY.

1 answer

0

Your question is confused. If you filter only month 8 for the one-way and month 8 for the back you put in condition:

WHERE MONTH(ida) = $mes(valor inteiro) AND MONTH(chegada) $mes(valor inteiro)

Browser other questions tagged

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