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
{{ message }}
Repository navigation
DATETIME converted to string but Tedious driver expects date #546
I initially made a pull request on the tedious project to match DATETIME2 with DATETIME in that it converts the parameter (a string) to a date but a contributor over there said the whole file needs re-though. In the meantime we are stuck with a broken node as passing a DATETIME parameter causes the process to crash. Starting on line 166 https://github.com/patriksimek/node-mssql/blob/master/lib/datatypes.js you take a date and convert it to a string which results in the process crashing with "TypeError: parameter.value.getTime is not a function" The only two solutions is to convert the string to a date (currently I have modified the tedious driver to to this) or send a date to the tedious driver. I hope you two can work it out.
changed the title [-]DATETIME converted to number but Tedious driver expects date[/-][+]DATETIME converted to string but Tedious driver expects date[/+]on Oct 23, 2017
@atsage do you know if this ever got fixed? Using this library for the first time and having the same problem. If not do you mind sharing your modifications?
Activity
[-]DATETIME converted to number but Tedious driver expects date[/-][+]DATETIME converted to string but Tedious driver expects date[/+]mjodeh commentedon Jul 29, 2018
node_module\tedious\lib\data-types\datetime.js
from line 29:
if (options.useUTC) {
var dateTest = new Date(parameter.value);
days = Math.floor((parameter.value - UTC_EPOCH_DATE.getTime()) / (1000 * 60 * 60 * 24));
seconds = dateTest.getUTCHours() * 60 * 60;
seconds += dateTest.getUTCMinutes() * 60;
seconds += dateTest.getUTCSeconds();
milliseconds = seconds * 1000 + dateTest.getUTCMilliseconds();
} else {
var dateTest = new Date(parameter.value);
dstDiff = -(dateTest.getTimezoneOffset() - EPOCH_DATE.getTimezoneOffset()) * 60 * 1000;
days = Math.floor((dateTest.getTime() - EPOCH_DATE.getTime() + dstDiff) / (1000 * 60 * 60 * 24));
seconds = dateTest.getHours() * 60 * 60;
seconds += dateTest.getMinutes() * 60;
seconds += dateTest.getSeconds();
milliseconds = seconds * 1000 + dateTest.getMilliseconds();
}
dhensby commentedon Mar 8, 2019
I'm not really following this, @willmorgan: thoughts?
willmorgan commentedon Mar 8, 2019
It's a Tedious issue I'm afraid.
swordsreversed commentedon Jul 30, 2019
@atsage do you know if this ever got fixed? Using this library for the first time and having the same problem. If not do you mind sharing your modifications?
mjodeh commentedon Jul 30, 2019
@swordsreversed Just convert the parameter you are passing to "Date" type and do not pass it as a string object