© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago•
8 replies
terryball

Type error working with Postgres dates in v.0.30.1

I'm using Drizzle with postgresjs and recently updated to v0.30.1, where I know the driver was updated to always return strings for dates.

After the update, many of my queries then failed with an error
ERR_INVALID_ARG_TYPE
ERR_INVALID_ARG_TYPE
:
The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Date"
The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Date"
.

Here's an example of a failed query that produced that error message:

const startDate = subDays(new Date(), 30) // Date object

const results = await db
  .select({
    id: sessions.id,
    userId: sessions.userId,
  })
  .from(sessions)
  .where(gte(sessions.timestamp, startDate))
const startDate = subDays(new Date(), 30) // Date object

const results = await db
  .select({
    id: sessions.id,
    userId: sessions.userId,
  })
  .from(sessions)
  .where(gte(sessions.timestamp, startDate))


Where
sessions.timestamp
sessions.timestamp
is defined as
timestamp('timestamp', { mode: 'date', withTimezone: true })
timestamp('timestamp', { mode: 'date', withTimezone: true })
in my schema.

When I convert
startDate
startDate
to a string with
.toISOString()
.toISOString()
, the query works, but I get the following type error:

No overload matches this call.
  Overload 1 of 3, '(left: PgColumn<{ name: "timestamp"; tableName: "sessions"; dataType: "date"; columnType: "PgTimestamp"; data: Date; driverParam: string; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>, right: Date | SQLWrapper): SQL<...>', gave the following error.
    Argument of type 'string' is not assignable to parameter of type 'Date | SQLWrapper'.
  Overload 2 of 3, '(left: Aliased<string>, right: string | SQLWrapper): SQL<unknown>', gave the following error.
    Argument of type 'PgColumn<{ name: "timestamp"; tableName: "sessions"; dataType: "date"; columnType: "PgTimestamp"; data: Date; driverParam: string; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>' is not assignable to parameter of type 'Aliased<string>'.
No overload matches this call.
  Overload 1 of 3, '(left: PgColumn<{ name: "timestamp"; tableName: "sessions"; dataType: "date"; columnType: "PgTimestamp"; data: Date; driverParam: string; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>, right: Date | SQLWrapper): SQL<...>', gave the following error.
    Argument of type 'string' is not assignable to parameter of type 'Date | SQLWrapper'.
  Overload 2 of 3, '(left: Aliased<string>, right: string | SQLWrapper): SQL<unknown>', gave the following error.
    Argument of type 'PgColumn<{ name: "timestamp"; tableName: "sessions"; dataType: "date"; columnType: "PgTimestamp"; data: Date; driverParam: string; notNull: true; hasDefault: true; enumValues: undefined; baseColumn: never; }, {}, {}>' is not assignable to parameter of type 'Aliased<string>'.


Any tips would be appreciated. Thank you!
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Type error in 0.33.0
Drizzle TeamDTDrizzle Team / help
17mo ago
How to use custom date (1082) type parser in postgres.js for >0.30.0?
Drizzle TeamDTDrizzle Team / help
2y ago
drizzle-zod not working with column of type vector (as introduced in latest release v.0.31.0)
Drizzle TeamDTDrizzle Team / help
2y ago
New string mode date handling for postgres in 0.30.0 is potentially inconsistent
Drizzle TeamDTDrizzle Team / help
2y ago