Option 1: Use of TO_CHAR
:
select * from dados where TO_CHAR(data_registro, 'MM/YYYY') = '01/2016'
Option 2: Use with ranges:
select * from dados where data_registro >= '2016-01-01'::DATE
and data_registro <= '2016-01-31'::DATE
Option 3: Use of overlaps
select * from dados where (data_registro, data_registro)
OVERLAPS ('2016-01-01'::DATE, '2016-01-31'::DATE);
Option 4: With Extract
:
select * from dados
where
Extract(month from data_registro) >= Extract(month from '2016-01-01'::DATE)
and Extract(month from data_registro) <= Extract(month from '2016-01-31'::DATE)
Option 5: Use of intervals
based on current date:
SELECT *
FROM dados
WHERE Extract(month from data_registro) >= Extract(month from Now())
AND Extract(month from data_registro) <= Extract(month from Now() + Interval '20 day')
I took the test here of the first option and it worked, Perfect!
– Fernando josé