UTC problem and One Day Off
See original GitHub issueHello!
In node-mssql (6.3.1) / Tedious (6.7.0):
I’m having problems with not using utc in driver: setUTC = false.
If the hour of the date is anything is between 00:00:00 - 00:0:27, than, in database, it subtracts one day (???) of the Date.
For example:
Using new Date(2021, 4, 27, 0, 0, 27) to generate the Date (2021-05-27T03:00:27.000Z) (in backend) gives me 2021-05-26 00:00:27
Using new Date(2021, 4, 27, 0, 0, 28) to generate the Date (2021-05-27T03:00:28.000Z) (in backend) gives me 2021-05-27 00:00:28
Using new Date(2021, 4, 27, 0, 0, 0) to generate the Date (2021-05-27T03:00:00.000Z) (in backend) gives me 2021-05-26 00:00:00
The code/repro:
import * as sql from "mssql";
const pool = new sql.ConnectionPool({
user: "xxxx",
password: "xxxxx",
server: "xxxxx",
database: "xxxxx",
options: {
enableArithAbort: true,
useUTC: false,
trustServerCertificate: true,
},
});
async function start() {
const conn = await pool.connect();
let myDate = new Date(2021, 4, 27, 0, 0, 0);
console.log(myDate);
await conn.request().input("dt", sql.DateTime, myDate).query(`
UPDATE example
SET date= @dt
WHERE id= 1;
`);
const res1 = await conn.query(
"select date from example where id = 1"
);
console.log(res1.recordset);
await pool.close();
}
start();
In node-mssql (7.0.0-beta.5) / Tedious (11.0.5):
All things works as expected in same code.
For example:
Using new Date(2021, 4, 27, 0, 0, 0) to generate the Date (2021-05-27T03:00:00.000Z) (in backend) gives me 2021-05-27 00:00:00
But i can’t use mssql 7.0.0-beta.5. I’m using typeorm lib, and it ins’t compatible with the mssql 7.x version.
Anyone can help me?
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)

Top Related StackOverflow Question
We don’t generally backport fixes to old versions, because that’s a huge maintenance overhead and we’re basically just two people working on
tediousright now. How do you feel about this?A new version of
node-mysqlis in the works that updates to the latest version oftedious, so that might fix your issue soon? 🙇♂️@IanChokS, sorry, i think i don’t understand. Second argument refers to type of value or type of name of parameter.
What i want to say is that in older versions, the name of the parameter (first param of addParameter function - [number]
0 as any)could be anumber, for example? Or always the name of the parameter was a string?Because in older version of mssql, at least, i could pass a number as name of parameter, and it worked. This error is from it:
The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received type number (0)