Postgres birthdays selection

后端 未结 11 1210
猫巷女王i
猫巷女王i 2020-12-10 08:31

I work with a Postgres database. This DB has a table with users, who have a birthdate (date field). Now I want to get all users who have their birthday in the upcoming week.

11条回答
  •  时光说笑
    2020-12-10 08:48

    I have simply created this year date from original birth date.

    ( DATE_PART('month', birth_date) || '/' || DATE_PART('day', birth_date) || '/' || DATE_PART('year', now()))::date between :start_date and :end_date
    

    I hope this help.

提交回复
热议问题