tedious icon indicating copy to clipboard operation
tedious copied to clipboard

useUTC on Insert and Select

Open shiroze opened this issue 2 years ago • 6 comments

Software versions

  • Tedious: 15.1.3
  • SQL Server: 2016
  • Node.js: 18.10.0
  • node-mssql: 9.1.1

Connection configuration

const config = {
  server: 'MYSERVER',
  authentication: {
    type: "default",
    options: {
      userName: "db",
      password: "db@123"
    }
  },
  options: {
    useUTC: false,
    database: 'db_dev',
    encrypt: true,
    trustServerCertificate: true,
  },
};

Detail Reference is here Node-issue

shiroze avatar Mar 20 '23 01:03 shiroze

Hi @shiroze, just to make sure is this kind the query that you try to execute ?

function inputParameters() {
  // Values contain variables idicated by '@' sign
  const sql = `Insert into MyTable ( test_c3) VALUES (@time)`;
  const request = new Request(sql, (err, rowCount) => {
    if (err) {
      throw err;
    }

    console.log('rowCount: ', rowCount);
    console.log('input parameters success!');
  });

  // Setting values to the variables. Note: first argument matches name of variable above.
  request.addParameter('time', TYPES.DateTime, '2023-03-16 11:58:30');

  connection.execSql(request);
}

And you question is why the without set useUTC to false you get a different time? If I got your question right and the example that I put above if what your trying to do, then I can explain why the behavior is expected: On tedious side, our useUTC setting is default to true. Unfortunately, if you want to disable UTC, you have to explicitly set it to false in the configuration. Hope this answers' your question.

MichaelSun90 avatar Mar 20 '23 18:03 MichaelSun90

Yes, When doing insert with useUTC:false I got the correct time 2023-03-16 11:58:30 but when I select that data it return the UTC time 2023-03-16 04:58:30

shiroze avatar Mar 29 '23 06:03 shiroze

Hi @shiroze , Thanks for the reply and I am able to reproduce this behavior. Will keep investigating, and see if I can come up with a fix.

MichaelSun90 avatar Mar 29 '23 20:03 MichaelSun90

Hi @shiroze , Thanks for the reply and I am able to reproduce this behavior. Will keep investigating, and see if I can come up with a fix.

Hi @MichaelSun90 , Thank you hope this Bug can be Fixed ASAP. Thank you for the reply

shiroze avatar Mar 31 '23 06:03 shiroze

Hi @MichaelSun90, I do have the same problem as @shiroze . waiting for the feedback...

nanjarapalli avatar Apr 18 '23 08:04 nanjarapalli

Hi @nanjarapalli , we were looking into this #1467 , and this suppose to provide a better date time types support. Will continue working on this when we got the bandwidth, and update you guys if we make any progress.

MichaelSun90 avatar Apr 18 '23 17:04 MichaelSun90