Skip to content

Incorrect time from Types.DateTime #883

Closed

Description

@bitBrainResearch

When calling a usp which does no conversion and returns sql server's GetDate() function value as-is, the time returned using Types.DateTime is incorrect.

It's 10am, the (incorrect but doesn't matter) time zone is reported as GMT-0400. The time returned is 6am.

It appears as if someone was expecting GMT, modified it by the GMT offset and returned that. When instead, they are getting the correct time already modified and then are adding the offset a second time.

I'm getting:
Fri Mar 29 2019 06:37:14 GMT-0400 (Eastern Daylight Time)
From tedious

On sql server:
2019-03-29 10:37:38.943

On further experimentation, even pulling down the straight date without using a usp and thus not going through Types.DateTime still causes some parsing. So this might be a javascript thing although it seems weird that JS is just going to parse random values it might recognize. It makes more sense that tediousjs is parsing values like that?

I thought it might just be a ToString() style conversion but when I debugged I found that my returned date was the long string plus a whole bunch of time functions.

Activity

  1. MichaelSun90 commented on Apr 2, 2019

    @MichaelSun90
    Contributor

    Hi @bitBrainResearch
    I am not familiar with usp, but as you explained, it passes through the sql.getdate()'s value. From your example, I assume it is '2019-03-29 10:37:38.943'. I run some test on my side, create a data using JS date constructor 'new Date('2019-03-29 10:37:38.943')'. Then, call the writeParameterData under datetime.js from Tedious side. It seems to return the correct time 'Fri Mar 29 2019 10:37:38' on my side.

    I am not sure this is the reproduce step that you expect, or you can provide me come repo steps, so I can try it. Also, I remembered there were some discussion happened last year, and there was a fix mentioned. You can also try the lastest Tedious version is you are not currently using the latest one. See if that helps.

    For the last part of your issue: I am not sure I understood everything. "So this might be a javascript thing although it seems weird that JS is just going to parse random values it might recognize." What do you mean about the random values? For this part, "I thought it might just be a ToString() style conversion but when I debugged I found that my returned date was the long string plus a whole bunch of time functions.", which part you expect is a ToString() conversion? Some clarification will be extremely
    appreciated.

  2. IanChokS commented on Dec 13, 2019

    @IanChokS
    Member

    @bitBrainResearch Do you have a reproducible case for us to try out?

  3. added
    Idle
    on Dec 13, 2019
  4. IanChokS commented on Jan 2, 2020

    @IanChokS
    Member

    @bitBrainResearch This issue should be fixed by #1023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Idle

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions