You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Activity
MichaelSun90 commentedon Apr 2, 2019
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.
IanChokS commentedon Dec 13, 2019
@bitBrainResearch Do you have a reproducible case for us to try out?
IanChokS commentedon Jan 2, 2020
@bitBrainResearch This issue should be fixed by #1023