Leogreen
Leogreen

Reputation: 701

PostgreSql Select from where date = current Date

how can i select only the records from DB where the Data (Date in portuguese) = the current date

SELECT id, data, dia, mes, ano,fornecedor, doc, valor_líquido, total
FROM public.fluxo_pagamentos where data = current_date;   

Upvotes: 4

Views: 14644

Answers (2)

Y.S
Y.S

Reputation: 1862

cast to date and use now()

SELECT id, data, dia, mes, ano,fornecedor, doc, valor_líquido, total
FROM public.fluxo_pagamentos where data::date = now()::date;   

Upvotes: 11

Gordon Linoff
Gordon Linoff

Reputation: 1269853

I may suspect that data has a time component. If so, try:

where data >= current_date::timestamp and
      data < current_date::timestamp + interval '1 day'

Upvotes: 6

Related Questions