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

Date Parsing with DB2 driver #18

Closed
radiodario opened this issue Apr 10, 2012 · 5 comments
Closed

Date Parsing with DB2 driver #18

radiodario opened this issue Apr 10, 2012 · 5 comments

Comments

@radiodario
Copy link

First of all, thanks for these bidings, they are proving incredibly useful.

I'm using odbc version 0.3.1 (as installed from npm)

I'm encountering difficulties parsing TIMESTAMPS coming from a IBM DB2 driver:

var res = []; db2.queryDB('select eventdate from dev.trace_table order by EVENTDATE desc fetch first row only with ur', function(results) { res = results });
undefined
res
[ { EVENTDATE: Sun, 07 Dec 1969 09:03:09 GMT } ]

When I run the same query on isql i get the correct results i.e

SQL> select eventdate from dev.trace_table order by EVENTDATE desc fetch first row only with ur
+---------------------------+
| EVENTDATE |
+---------------------------+
| 2012-04-05 07:30:19.160547|
+---------------------------+
SQLRowCount returns -1
1 rows fetched

@radiodario
Copy link
Author

I forgot to mention that the db2.queryDB function is just a wrapper:

exports.queryDB = function(sql, callback) {
var db = new odbc.Database();
db.open("DSN=DATABASE;UID=dario;PWD=somepass", function(err)
{
if (err) {
//Something went bad
console.log(err);
//Let's not go any further
return;
}
db.query(sql, function (error, result, info) {
if (error) {console.log(error); return false;}
callback(result);
});

    });

}

@radiodario
Copy link
Author

I was able to fix this issue by casting to double before multiplication

tuple->Set(String::New((const char *)columns[i].name), Date::New(double(mktime(&timeInfo)) * 1000 ));

@wankdanker
Copy link
Collaborator

Hey @radiodario, Thanks for the report. I'll try out your fix to make sure it doesn't break MSSQL and anything else I can try. I'm glad you were able to get that working.

wankdanker referenced this issue in wankdanker/node-odbc Apr 10, 2012
@radiodario
Copy link
Author

thanks!

@w1nk
Copy link
Owner

w1nk commented Apr 11, 2012

Dan - if you can send me a pull req, I'll go ahead and merge it in. I'll find you on irc later today also!

@w1nk w1nk closed this as completed Apr 11, 2012
w1nk added a commit that referenced this issue Apr 11, 2012
Fix for #18 plus other goodies
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