How to Catch a Week Back from Today at Postgress

Asked

Viewed 37 times

0

I’m trying to make a select to pick a week back from today. That’s what I’ve come up with?

select count(id) as total, (current_date - interval '7') as testando, extract(day from data_cadastro) as date_part,extract(month from data_cadastro) as date_part_month
from ris_atendimento as a
group by 
    extract(day from data_cadastro), extract(month from data_cadastro)  
order by 
    date_part asc;
  • Have tried using (CURRENT_DATE - INTERVAL '7 DAYS'), instead of just (current_date - interval '7')?

  • If you just want to catch "a week back from today" then you need to put such a condition in the WHERE.

  • explain better exactly what you want and the expected result basically the 7 days would be just like this: select 
count(id) as total,
(current_date - interval '7 days') as testando
from ris_atendimento as a otherwise try to complement.

No answers

Browser other questions tagged

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