Forum Discussion

vamshi9666's avatar
4 years ago

time constraint in v2 json query

i am trying to get occasions with ```end_time``` constraint using "GET" /search/2.0 query as follows:  <code>   var liql = "SELECT  body, cover_image, subject,occasion_data.rsvp.user, occasion_dat...
  • vamshi9666's avatar
    4 years ago

    I solved this by using converting time value into unix timestrap format by Date.now().

     

     

    updated query looks like : 

    <code>

     var currentDate = Date.now()
     var liql = "SELECT  body, cover_image, subject,occasion_data.rsvp.user, occasion_data.location FROM messages where occasion_data.end_time >= " + currentDate
                var jsonQuery = [{
                    messages: {
                        fields: ["occasion_data""body""cover_image""subject""occasion_data.rsvp"],
                        constraints: [{
                            "occasion_data.end_time": {
                                ">=": currentDate
                            }
                        }]
                    }
                }]

    </code>