George Lewis
10/11/2021, 12:00 AMconst users = await ctx.prisma.user.findMany({
where: {
profile: {
firstName: {
contains: args.where.firstName
},
DOB: {
}
}
}})
Hi All, need your help .. I am trying to build a query that returns a list of users that have a birthday today .. there is a filed in the user model that has the DOB stored .. Is there anyway to do so?Ricky Hopkins
10/11/2021, 12:23 AMDOB: {
gte: "2021-10-11",
lt: "2021-10-12"
}
You would obviously want those dates to be dynamically generatedTyler Clendenin
10/11/2021, 12:24 AMDOB: new Date().setUTCHours(0, 0, 0, 0)George Lewis
10/11/2021, 2:08 AMGeorge Lewis
10/11/2021, 2:16 AMRicky Hopkins
10/11/2021, 2:18 AMRicky Hopkins
10/11/2021, 2:18 AMGeorge Lewis
10/11/2021, 4:11 AMTyler Clendenin
10/11/2021, 4:27 AMRicky Hopkins
10/11/2021, 6:04 AMDATE_PART function in postgres.
https://stackoverflow.com/questions/6758778/getting-all-entries-whose-birthday-is-today-in-postgresqlRicky Hopkins
10/11/2021, 6:04 AMprisma.$queryRaw`SELECT * FROM User`Maciek K
10/11/2021, 9:31 AM"1990-04-30", "19900430" or an integer 19900430.
Because you don't want somebody's birthday to be on different days on different timezones. It might bit you someday, dealing with timezones is hard.
If you're storing ISO format without time then you can use `endsWith`:
DOB: {
endsWith: '10-11' // you would make that string earlier using todays date
}
Further reading: https://stackoverflow.com/questions/33129478/store-date-of-birth-in-database-as-unix-time/33130024#33130024