0

Is there a way to query from parse.com CreatedAt column by the time only? My goal is to query all the records that were CreatedAt between say 6 and 12 o'clock regardless of the date (though I will need to attach some date range also). I am using parse's .NET API. In my mind I thought something like this might work, but sadly all I got was InvalidOperationException:

pQuery = from hit in pQuery 
    where ((DateTime)hit.CreatedAt).Hour >= 6 
       && ((DateTime)hit.CreatedAt).Hour <= 12
    select hit;

Of course I always could filter results after the query using business logic, but that would hinder the performance. Would love a query solution.

2
  • That pQuery on both sides of the = looks odd to me Commented Oct 15, 2014 at 13:54
  • Well it is relating to the previous query. You could imagine second pQuery as being just ParseObject.GetQuery("Hits"). Commented Oct 15, 2014 at 16:43

1 Answer 1

1

I don't think you can do it the way you're thinking - the createdAt field is just a UNIX timestamp. Instead, you could try adding a new field (or fields) to track the time. Create a beforeSave method for that class that populates those fields anytime a new object gets created. Then you can query against those new fields.

The tricky part here will be dealing with timezones, so take that into consideration.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.