Knex.js allows you to use the .whereBetween() method to include dates that

While running a filter query to get records within a specific date range, I noticed that it's including records from a day before the actual range. Here is an example:

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

https://i.sstatic.net/aiKrx.png

For instance, when selecting 01/19/2022 - 01/26/2022, it retrieves a record from 01/18/2022 inexplicably. Has anyone encountered this issue and knows why it might be happening?

Answer №1

Issue Resolved!

const response = await db('message_records as m')
      .join('users', 'm.user_id', '=', 'users.id')
      .select('m.*')
      .where('uuid', uniqueId)
      .whereRaw('date_format(m.createdTime, "%Y-%m-%d") BETWEEN ? AND ?', [req.query.startDate, req.query.endDate]);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to update the selected autocomplete item in Vue using programming techniques?

Although I am still learning Vue, consider the following scenario: <v-autocomplete v-model="defaultUser" :hint="`User: ${defaultUser.username}`" :items="users" :item-text="item =>`${item.firstName} - $ ...

Data retrieval seems to be encountering issues in Firefox and IE9, whereas Chrome and Safari are functioning without any problems

I am using the following method function callCommentservice() { try { // Comment Service Url var getCommentServiceUrl = self.commentsServiceUrl + self.getRating + "tenantId=" + self.tenantId + "&ratedObjectTypeId=" + sel ...

What is the best way to obtain / and /:specificText in node.js?

app.get('/',function(req,res,next){ app.use(express.static(html file); next(); }); app.get('/:someText',function(req,res){ var x = req.params.someText; res.send(x); }); Even though I am able to get the output for bot ...

Code snippet in webpage body

Hey there, I could really use some assistance: I currently have the following: A) Login.html B) Documentation.html C) Base.html Within the login page, there is a form with fields for User and Password. In Documentation, there are links to various folder ...

Inquirer doesn't waste time lingering for user input following a prompt

After initiating the prompt, I'm encountering an issue where inquirer doesn't pause for user input and instead immediately advances to the next command line. Below is the code I'm using: import inquirer from 'inquirer'; var link; ...

Avoid displaying a popup menu on the webpage during page refresh

How can I prevent a popup menu from appearing again after refreshing the page? I have tried using some javascript but haven't been successful. If anyone has a solution, such as a video tutorial or code snippet, please let me know. ...

How can you configure nodemon to avoid the EADDRINUSE error when working with express and preventing it from listening on a port that is already being used?

I'm currently experimenting with a tutorial on creating a slack bot using an express server that runs concurrently with nodemon and ngrok. However, I've hit a roadblock: Error: listen EADDRINUSE: address already in use :::5000 I suspect this ...

Maintain the proportion of the browser window when reducing its size

<html> <head> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <img src="spacer--1200x800.png" width="1200" height="800" /> </body> </html> This section contains CSS ...

Build a React application using ES6 syntax to make local API requests

I'm really struggling to solve this problem, it seems like it should be simple but I just can't figure it out. My ES6 app created with create-react-app is set up with all the templates and layouts, but when trying to fetch data from an API to in ...

Exploring Laravel 5.2: A guide on fetching information from a one-to-one eloquent relationship using the hasOne method

I have two Models: 1. Course. 2. Fee. There seems to be an issue with accessing the fee data for a course in my application. Even though I am able to input the data without any problem, when trying to retrieve it, the fee column appears empty. How can I r ...

How can I delete the black background from the ion-tab-bar in Ionic 7?

In my current project using Ionic 7, I have a navigation guide set up with 4 tabs. I am trying to customize the styling of these ion tabs by adding some custom CSS. The issue I'm facing is that despite my attempts to make the background transparent, ...

Incorrect calculation of offsetWidth occurs in presence of special characters within text

I'm currently trying to determine the width of a specific text in my scenario. Below is a simple example of my code: var text = "Country <textinbrackets> and some following text"; var textObj = document.createElement('text'); $(textOb ...

Tips for sending multiple forms and having PHP interpret it as a single form using $.ajax

I am working on an email function using $.ajax with 3 different forms that are loaded through an ajax request. When a user clicks on a button, the current form will disappear and a new form will appear. The challenge I am facing is how to send data from al ...

Leveraging global variables within Vuex state management strategy

I have successfully added custom global variables into Vue by injecting them. Here is the code snippet: export default function (props, inject) { inject('models', { register(name) { const model = require(`@/models/${name}. ...

Displaying a loading GIF during a standard form submission

I am facing a challenge with a form in my concept, as it takes at least 10-15 seconds to load due to a large number of records. While I know I could use AJAX to display a loading GIF and load the records simultaneously, I am wondering if there is a way t ...

Utilizing JavaScript and PHP to dynamically load HTML content on a webpage

Below is the code snippet I'm working with: <?php if ($x == 1){ ?> <b>Some html...</b> <?php } else if ($x==2){ ?> <b> Other html...</b> <?php } ?> Now, I want to create two links (a ...

It appears that the NodeJs Express 4 async function in the model is returning before completion

I'm currently working on organizing my project by splitting the logic into different folders such as routes, views, models, and controllers. Within a model named data (models/datamodel.js), I have implemented two methods to retrieve data for populati ...

Tips for optimizing data retrieval from a MongoDB collection by leveraging Node.js, Mongoose, and MongoDB connections efficiently

In my scenario, I have two key collections: orders and driverResponse. The driver has the ability to either accept or decline an order, with his response being saved in the driverResponse collection. When the driver revisits the order, it is important to ...

What is the mechanism of interaction between sessions in PassportJS?

I've been struggling to grasp the login and signup process in PassportJS and ExpressJS. My goal is to test whether multiple sessions are being generated. To do this, I set up a server and opened two browser windows, each on the login page. After loggi ...

JS - Reducing in size increases request size

I'm facing an issue with compressing my request - instead of reducing the size, it seems to be increasing it: const requestData = LZString.compress(JSON.stringify({ data: bigBase64StringHere })); await axios.post("api-endpoint", requestData, ...