Knex.js .whereBetween() includes date before


I am running a filter query and getting records between a certain date range, for some reason, it’s grabbing records a day before my range. For example:

.whereBetween('created_at', [dateRange.from,]);

enter image description here

When I select 01/19/2022 - 01/26/2022 it grabs a record from 01/18/2022 for whatever reason, does anyone know why this is happening?


Solved !!!

const result = await db('messages_logs as a')
      .join('users', 'a.user_id', '=', '')
      .where('uuid', uuid)
      .whereRaw('date_format(a.createdAt, "%Y-%m-%d") BETWEEN ? AND ?', [req.query.start, req.query.end]);

Answered By – Pash

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published