How do I obtain the 1st and 15th day of each month for a period between two dates? Exampl开发者_如何学Pythone that does not work:
SELECT * FROM daily_data
WHERE (`date` < '$des' AND `date` > '$has')
AND (`date` LIKE '%-%-01' AND `date` LIKE '%-%-15');
select * from table where day(date_field) in (1,15)
so your query I think it would become
select * FROM datos_diarios WHERE Fecha between '$des' and '$has' AND day(Fecha) in (1,15)
edit. Just for your knowledge it would be possible to use a wildcard char with like. Something like this:
select * from table
where
date_field like '____-__-01'
or
date_field like '____-__-15'
but it's better if you use day() function.
精彩评论