3
I have a table called Entrega
where all deliveries made with their respective dates are stored, how can I bring only deliveries from the last 15 days? Doing so I can bring deliveries from the day 10 of 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 so that it becomes something more dynamic?
Recalling that this query, in addition to returning records from 15 days ago, also returns records from tomorrow until the end of time.
– Lacobus
@Lacobus, but why does she return the records from tomorrow to infinity? Whenever I run this query she is bringing me the correct result
– R.Santos
What I mean is, the break is infinite if
data >= CURRENT_DATE - 15
. If there is any record that shows date future (in relation to current date) in the fielddata
this will also be returned. To recover onlyúltimos 15 dias
it would take something like:data >= CURRENT_DATE - 15 AND data <= CURRENT_DATE
– Lacobus
For example if by chance there is a record with a date
20/10/2017
today in the bank it would be returned in the case? Even using theCURRENT_DATE
?– R.Santos
That’s right! If you are only applying the condition
data >= CURRENT_DATE - 15
dates future will be returned. If today is16/10/2017
all records of20/10/2017
would be returned too!– Lacobus