-- if column has type date ('2018-09-01') it's easy to compare
select * from ... where period_to between '2018-09-01' and '2018-09-30';
--if whe have datetime ('2018-09-01 12:13:08.927262') we need to add extra one day to last date and extract from it milisecond which gives us: '2018-09-30 23:59:59.900000'
-- without it we will have only range between: 2018-09-01 and 2018-09-29
select * from ... where created_at between '2018-09-01' and '2018-09-30' + INTERVAL 1 DAY - INTERVAL 1 SECOND_MICROSECOND;