How to get records for the last 15 days - PostgreSQL

2

I have a table called Entrega where all the deliveries made with their respective dates are stored, how can I only deliver deliveries from the last 15 days? Doing so I can deliver from 10 October, for example:

SELECT * FROM public.entrega where data >= '2017-10-10' order by data desc;

But how can I determine the last 15 days for something more dynamic?

    
asked by anonymous 13.10.2017 / 16:46

2 answers

2

After adapting what was found here my query stayed like this and I got what I needed:

SELECT * FROM public.entrega where data >= CURRENT_DATE - 15 order by data desc;
    
13.10.2017 / 16:52
1

Retrieves the records contained in the public.entrega table that have the data field filled with dates from the last 15 days, without considering future dates.

SELECT
    *
FROM
    public.entrega
WHERE
    data BETWEEN CURRENT_DATE - '15 days'::interval AND CURRENT_DATE
ORDER BY
    data DESC;
    
13.10.2017 / 23:34