select from date in the postgreSQL database

Posted on

Question :

How do I make a select in the postgreSQL database for it returns the data from a specific date, for example I have a field of type timestamp with name data_interview, I want it to bring me the data registered from the present day forward .

SELECT * FROM tabela Where data_entrevista = data de hoje para frente


Answer :

Use >= to bring only recent dates:

SELECT * FROM tabela Where data_entrevista >= '2016-10-19 00:00:00' 


As the field is timestamp (date and time) you can cast% ( ::tipo ) to date and compare with current date CURRENT_DATE

SELECT * FROM tabela Where data_entrevista::date >= CURRENT_DATE

Postgres – documentation – Datetime


Leave a Reply

Your email address will not be published. Required fields are marked *