-
Notifications
You must be signed in to change notification settings - Fork 435
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
Problem with date strings #339
Comments
Can you do me a favor and check if you also face this issue with version And you're right, the parameter handling code is a bit iffy. |
Yes, I cannot see any difference with 1.11.5 |
Ok, thanks for letting me know. I just wanted to verify this was not a regression introduced in |
I also ran into this problem. The workaround is the following: var str = "2016-03-10T19:36:16.105Z";
var d = new Date(str);
if (isNaN(d)) {
// throw error about invalid date string
} else {
request.addParameter('DateCreated', TYPES.DateTime, d);
} It would be nice if tedious performed this check when adding a parameter. function addParameter(name, type, value) {
if (typeof value === 'string' && (type === TYPES.DateTime || type === TYPES.DateTime2)) {
value = new Date(value);
}
// ... remaining code stays the same
} |
THIS ISSUE IS NEARLY 2 YEARS OLD
To reproduce add a parameter that is a SmallDateTime.
|
This only occurs when options.useUTC is set to false, and the parameter value is something tedious needs to parse e.g. a string containing a date. Tedious uses Date.parse to parse the string, which returns a number of milliseconds, then later tries to call getTimezoneOffset on that value. |
Appears to be caused by: f360b09 |
Looks like https://github.com/tediousjs/tedious/pull/677/files will resolve it. |
This fixes the issue described in #339.
This fixes the issue described in #339.
This fixes the issue described in #339.
🎉 This issue has been resolved in version 6.6.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I'm trying send date strings to the database and I'm having some issues.
This is my sample query:
SELECT @p0 AS a
And the parameter is:
'2015-10-31 00:00:00'
I have tried these datatypes with similar result: DateTime, DateTime2, DateTimeOffset
This is the error message:
The issue seems to be that the value is converted from a string to an integer in the validate method in data-type.js. The value after the conversion is 1446246000000. It seems to me that this should really be a Date object and not a number.
I can work around this bu sending in real Date objects, but I still think this is an issue that should be solved.
The text was updated successfully, but these errors were encountered: