I'm trying to compare some dates for a ParseQuery. It doesn't give me errors but it just doesn't filter the dates. Here's some code:
if(dateFrom!=null){
query.whereLessThanOrEqualTo("from", dateFrom);
}
if(dateTo!=null){
query.whereGreaterThanOrEqualTo("to", dateTo);
}
date is java.util.Date (not sql)
Date dateFrom = new Date(fromYear,fromMonth,fromDay,fromHour,fromMinute);
Date dateTo = new Date(toYear,toMonth,toDay,toHour,toMinute);
when I look at my ParseObjects on parse.com, I see the objects got a dateFrom and dateTo.
Can somebody tell me why it doesn't filter? Thank you
I've tested that Date Comparisons work with the Javascript SDK.
(word is a basic parse model)
var d = new Date();
var word = new Word();
word.set("dateTo", new Date (2012, 01, 01));
word.save();
var dateTo = new Date (2012, 12, 31);
var query = new Parse.Query(Word);
query.greaterThan("dateTo", dateTo);
query.find({
success: function(results) {
alert("Successfully retrieved " + results.length + " scores.");
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
As a workaround you could always transfer your days into seconds like Date.getTime() and use integers for the comparison.
regards
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With