select from date in postgresql database

Asked

Viewed 10,321 times

8

As 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 brings me the data registered since today forward.

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

    in fact, the right term would not be "today’s", and yes "of a specific day". Today will always happen, forgetting the previous dates (this saying, for being able to use the now())

3 answers

5


Utilize >= to bring only more recent dates:

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

4

Since the field is timestamp (date and time) you can cast a (::tipo) for date and make the comparison only with the current date CURRENT_DATE

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

Postgres - documentation - Datetime

-2

Thus:

SELECT * FROM table Where data_interview::date = '2019-10-16'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.