Search code examples
objective-cnsdatebackendless

Backendless filter results based on current date


I have this query

https://api.backendless.com/v1/data/abc?pageSize=100&loadRelations=cinema&sortBy=showing%20asc&where=objectId%3D%272C225111-18FC-DD4F-FF40-E227F49F5B00%27%20AND%20showing%20%3E%20%2714-June-2016%27

Thi query rightly fetches all the results after the date 14 June 2016. But I am giving a hard coded date here, Is there any way I can simply add current time/date here so that It brings all the results prior to current time? I am looking for something like

https://api.backendless.com/v1/data/abc?pageSize=100&loadRelations=cinema&sortBy=showing%20asc&where=objectId%3D%272C225111-18FC-DD4F-FF40-E227F49F5B00%27%20AND%20showing%20%3E%20%CURRENT TIME%27

I have searched alot, and even the documentation refers to hardcode dates or millisecond format only. Any help is appreciated


Solution

  • The easiest option is just to use the UNIX timestamp version of the date, so the string to use in your where clause would be like:

    NSString *where = [NSString stringWithFormat:@"showing < %@", [[NSDate date] timeIntervalSince1970]];