Date condition on where function

Hello everyone, so I have this schema of accounts and I want to get all the data from the current date
export const accounts = mysqlTable("account", {
...
date: date("date").notNull(),
userId: varchar("userId", { length: 191 }).notNull(),
});
export const accounts = mysqlTable("account", {
...
date: date("date").notNull(),
userId: varchar("userId", { length: 191 }).notNull(),
});
I'm using this query like this and I'm not getting anything back
const userAcounts = await db
.select({
amount: sql<number>`sum(${accounts.amount})`,
date: accounts.date,
type: accounts.type,
})
.from(accounts)
.where(and(eq(accounts.userId, user?.id!), eq(accounts.date, new Date())))
.groupBy(accounts.date, accounts.type)
.orderBy(desc(accounts.date));
const userAcounts = await db
.select({
amount: sql<number>`sum(${accounts.amount})`,
date: accounts.date,
type: accounts.type,
})
.from(accounts)
.where(and(eq(accounts.userId, user?.id!), eq(accounts.date, new Date())))
.groupBy(accounts.date, accounts.type)
.orderBy(desc(accounts.date));
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server