I have a problem that involves the WHERE
clause of my query:
...
WHERE distinct_policy.policy_created_date_time between '2023-03-01' and '2023-03-11'
The column "policy_created_date_time" is a timestamp without time zone. I want to select only ten days (first March – tenth March), but in any year (not just in 2023).
Is there any simple way to do it, because sql doesn’t allow me just to delete the year.
2
Answers
One option is to check on months and days, by extracting directly those parts, using
EXTRACT
.You can use generate_series and a range data type to solve this issue. You now can also use an (existing) index on your column.
This example takes the next 100 years, you could take a different start or end.