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

Cordova SQLite DATE conditioned query #415

Closed
mareksip opened this issue Feb 5, 2016 · 2 comments
Closed

Cordova SQLite DATE conditioned query #415

mareksip opened this issue Feb 5, 2016 · 2 comments

Comments

@mareksip
Copy link

mareksip commented Feb 5, 2016

I have Receipt table that I am trying to SELECT data from by conditions in DATE datatype column.

The format in Browser (WebSQL) like this:

DateIssue DATE format: Thu Feb 04 2016 23:09:15 GMT+0100 (Střední Evropa (běžný čas))

My query:

tx.executeSql('SELECT ri.ProductId, ri.Name as riName FROM ReceiptItem ri INNER JOIN
Receipt r ON r.ID = ri.ReceiptId WHERE   
r.DateIssue >= ? AND r.DateIssue <= ? GROUP BY ri.ProductId', [dateFrom, dateTo], function..

[dateFrom]
Mon Feb 01 2016 23:59:59 GMT+0100 (Střední Evropa (běžný čas))

[dateTo]
Mon Feb 29 2016 23:59:59 GMT+0100 (Střední Evropa (běžný čas))

No records get selected. Is SQLite supporting standard JS date data type?

This is how I parse the input date:

//Parse TO DATE
var dTo = $scope.data.dateTo;
dTo.setHours(23, 59, 59);
var toParsed = Date.parse(dTo);
var dateToFull = new Date(toParsed);
@brodycj
Copy link
Contributor

brodycj commented Feb 7, 2016

I just saw your report. The plugin does not explicitly deal with the Javascript Date object.

As a workaround you should be able to use built-in sqlite functions to deal with the conversions. Here are a few resources I found:

Thanks for reporting. I will investigate this when I get a chance.

@mareksip
Copy link
Author

mareksip commented Feb 7, 2016

@brodybits Thanks for response, I have solved conditioning by storing UNIX timestamp with .getTime() JS function.

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

No branches or pull requests

2 participants