Filtering by Date - Help on query content

9 posts, 0 answers
  1. Chris
    Chris avatar
    2 posts
    Member since:
    Mar 2015

    Posted 31 Mar 2015 Link to this post

    Trying to filter table data using the ModifiedAt but keep getting the "Invalid filter expression" error.

    I'm posting this in the header:
    X-Everlive-Filter: {"ModifiedAt" : {"$gte" : 2015-03-30T00:00:00.000} }
    The error returned is:
    {"message":"Invalid filter expression.","errorCode":608}

    Can anyone advise on the correct format/query string?

    I'm assuming I've got the format wrong as a simple Name filter works Ok:
    X-Everlive-Filter: {"Name" : "Bananas3"}

  2. Dimitar Dimitrov
    Admin
    Dimitar Dimitrov avatar
    26 posts

    Posted 31 Mar 2015 Link to this post

    Hi Chris,

    You have to put the date in quotes.
    Here is the correct filter: 
    {"ModifiedAt" : {"$gte" : "2015-03-30T00:00:00Z" } }

    If you need more help, do not hesitate to contact us.

    Regards,
    Dimitar Dimitrov
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  3. Chris
    Chris avatar
    2 posts
    Member since:
    Mar 2015

    Posted 31 Mar 2015 in reply to Dimitar Dimitrov Link to this post

    ah, of course......It worked.

    Thanks
  4. Dimitar Dimitrov
    Admin
    Dimitar Dimitrov avatar
    26 posts

    Posted 01 Apr 2015 Link to this post

    I'm glad it worked.

    If there are more problems, feel free to post here.

    Regards,
    Dimitar Dimitrov
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  5. Michael
    Michael avatar
    15 posts
    Member since:
    Jun 2015

    Posted 08 Oct 2015 Link to this post

    In a cloud fonction, i am using the javascript SDK.
    In this case, what is the format for filtering by date?

     yyyy-mm-ddT00:00:00.000Z ?

     yyyy-mm-ddT00:00:00Z ?

    thank you ​

    ------- code -------

    var ​data = Everlive.Sdk.$.data('objectType');
    var filter={ "​date_field" : { "$lt" : "yyyy-mm-ddT00:00:00.000Z" }};
    data.destroy(filter,success,error});

  6. Michael
    Michael avatar
    15 posts
    Member since:
    Jun 2015

    Posted 08 Oct 2015 in reply to Michael Link to this post

    or ​mm/​dd/yyyy 12:00 AM?
  7. Michael
    Michael avatar
    15 posts
    Member since:
    Jun 2015

    Posted 08 Oct 2015 in reply to Michael Link to this post

    or can i use just mm/​dd/yyyy?
  8. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 13 Oct 2015 Link to this post

    @Michael

    Consider the following example using the Date JavaScript object which is the proper way to filter on Date values:

    Copy Code
    var today = new Date();
    var query = new Everlive.Sdk.Query();
    var todayMinusOneDay = today.setDate(today.getDate() - 1);
     
    query.where().lt('CreatedAt', new Date(todayMinusOneDay )); // all items created before one day
     
    data.destroy(query, function(data) {
        response.body = data;
        done();
    }, function(err) {
        response.body = err;
        done();
    });

    Let me know if this works for you.



    Regards,
    Anton Dobrev
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  9. Michael
    Michael avatar
    15 posts
    Member since:
    Jun 2015

    Posted 13 Oct 2015 in reply to Anton Dobrev Link to this post

    perfect, thanks  a lot
Back to Top