Reputation: 4780
I need to extract all objects created within the current month.
so what I have done thus far is:
DateFormat df = new SimpleDateFormat("mm dd, yyyy");
String date = df.format(new Date());
ParseQuery<ParseObject> query = ParseQuery.getQuery("beer_rating");
query.whereEqualTo("userId", userId);
query.whereGreaterThanOrEqualTo("createdAt", date);
query.countInBackground(new CountCallback(){...
this is returning zero me...I know this isn't correct as logically it would only count what was created today...would anyone have any input on this? how to count all objects created within the current month?
Upvotes: 1
Views: 1684
Reputation: 9952
Calendar.getInstance().set(Calendar.DAY_OF_MONTH, 1);
will adjust the date to the first of the current month.
Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_MONTH,1); Date date = calendar.getTime();
ParseQuery<ParseObject> query = ParseQuery.getQuery("beer_rating");
query.whereEqualTo("userId", userId);
query.whereGreaterThanOrEqualTo("createdAt", date);
query.countInBackground(new CountCallback(){...
Upvotes: 1
Reputation: 4780
Big thanks to @Handsomeguy to pointing in the right direction I made the following changes and it works like a charm...
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH,1);
Date date = calendar.getTime();
so big thanks to the input of @Handsomeguy!
Upvotes: 0