testing495
testing495

Reputation: 272

Select all rows with date column equal to today's date in postgres to the minute

I essentially want to run a query like:

SELECT * FROM t where date={time right now to the minute}

Upvotes: 0

Views: 971

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269593

Use date_trunc() for your exact question:

where date = date_trunc('minute', now())

However, I suspect you really want the span of one minute:

where date >= date_trunc('minute', now()) and
      date < date_trunc('minute', now()) + interval '1 minute'

Upvotes: 4

Related Questions