I need help with SQL request!

I am trying to find in the database all the records I am interested in and made this query for this purpose.

SELECT *
FROM public.offer
WHERE status = ‘1’
AND created_at BETWEEN ‘2024-05-07’ AND ‘2024-05-07’;

Dates, respectively, are dynamic. The problem is that the second date is considered incorrectly. For example, if I need to find records for the period from May 6 to May 7 and if I specify the corresponding dates as parameters, it will return records only for the 6th day. To find records from 6 to 7 inclusive, I have to specify dates from 6 to 8 as parameters.
Could you please tell me what I need to change to make the search inclusive of these dates when specifying the dates?
Безымянный

Pay attention that there is date in request but datetime in the created_at field.
SQL consider time for this date as 00:00:00.000.
So you should specify the time for your ending date (this could be 23:59:59.999) or add 1 day to it.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.