Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useUTC on Insert and Select #1528

Open
shiroze opened this issue Mar 20, 2023 · 6 comments
Open

useUTC on Insert and Select #1528

shiroze opened this issue Mar 20, 2023 · 6 comments

Comments

@shiroze
Copy link

shiroze commented Mar 20, 2023

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

@MichaelSun90
Copy link
Contributor

MichaelSun90 commented Mar 20, 2023

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.

@shiroze
Copy link
Author

shiroze commented Mar 29, 2023

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

@MichaelSun90
Copy link
Contributor

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.

@shiroze
Copy link
Author

shiroze commented Mar 31, 2023

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

@nanjarapalli
Copy link

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

@MichaelSun90
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants