Postgresql – Search for current month data in postgresql 9.2

postgresql-9.2

I am trying to get the ticket data in a 9.2 database only from the current month.

The field called data_cadastro is DATETIME.

 id_ticket |    data_cadastro
-----------+---------------------
      2521 | 2017-10-31 08:11:48

how should I do ?

Best Answer

This is what you need:

SELECT *
FROM ticketdata
WHERE data_cadastro >= date_trunc('month', CURRENT_DATE);