Hi, If I have a date column and want to get annive...
# help
d
Hi, If I have a date column and want to get anniversary/birthday (i.e. day and month match but not year) how can I do it with the Supabase API? The filters I have tried haven't worked This works in the supabase UI sql editor:
Copy code
SELECT
  dob
FROM bday
WHERE date_part('day', dob) = date_part('day', CURRENT_DATE)
  AND date_part('month', dob) = date_part('month', CURRENT_DATE)
k
you could have 2 separate fields for bday_month and bday_day, I don't think there's a month+day type in PostgreSQL
You could use Computed Columns to add such columns, and then use them in filters: https://postgrest.org/en/v9.0/api.html#computed-columns
(well, you could also use PostgreSQL computed columns here if you need to index the (bday_month, bday_day))
d
Thanks, I'll look in to that
m
I would create a view or function to get the birthdays.
k
just be careful with views and RLS - views are evaluated as whoever created them, and often skip your RLS. Except if you have a view like select * from some_security_invoker_function()
m
Thanks @ktosiek I was not aware of it.
d
Thanks I tried to create a view and a function but couldn't quite get them working. There was an error about the public schema. I'll give it another shot