Records Query on DATE Fields per Month

1

Hello! I would like an aid I am performing queries on a VIAJEM table where I have 2 fields IDA E CHEGADA . Both of type DATE . I need to query all records for a given MES .

Ex. ida = '2016-08-15' chegada= '2016-09-01' . Although the arrival is in September the consultation must 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 catch the variable via $post and then replace it with QUERY.

    
asked by anonymous 17.08.2016 / 20:59

1 answer

0

Your question is confusing. If you only filter the month 8 for the one and the month 8 for the return you put in the condition:

WHERE MONTH(ida) = $mes(valor inteiro) AND MONTH(chegada) $mes(valor inteiro)
    
17.08.2016 / 21:25