Filtering orders by date range

markguertinmarkguertin Member Posts: 61
edited May 2018 in Development
Hi there, just working through some of the basic API docs and using the downloaded demo, but I've run into something that I can't seem to resolve. I'm trying to filter some of the test data on a date range and I'm specifying like this (but it errors). When I use either of the filters on their own they work fine, but putting them together with AND doesn't work. I'm not sure why, should I be using something different to achieve this? I haven't seen much of anything about advanced filtering in any of the docs I've read so far.

P.S. The formatting on this forum post page is pretty wonky and can't seem to parse basic tags LOL

lsserver.search.filters.created_date >= '2018-05-01' AND lsserver.search.filters.created_date <= '2018-05-31'

4 comments

  • jamesratcliffejamesratcliffe Administrator, Lightspeed Staff Posts: 160 moderator
    @markguertin Because the payload is XML, you can't use a literal '<' or '>' in the filter string. They should encoded:
    <search>
    <search_query>
    <columns>
    <column id="lsserver.search.column.id"/>
    </columns>
    <filters>lsserver.search.filters.created_date &gt;= '2018-05-01' AND lsserver.search.filters.created_date &lt; '2018-05-31'</filters>
    </search_query>
    </search>
    James Ratcliffe
    Lightspeed HQ
  • jamesratcliffejamesratcliffe Administrator, Lightspeed Staff Posts: 160 moderator
    To post that XML snippet, I had to run the whole thing through an encoder so that the browser doesn't interpret it as HTML.
    James Ratcliffe
    Lightspeed HQ
  • markguertinmarkguertin Member Posts: 61
    Ahh ok that works, thanks. Very odd that they work ok unencoded if you use singles (and I copied and pasted directly from the API tutorials).

    Thanks again, working as expected now.
  • markguertinmarkguertin Member Posts: 61
    Actually now that I think about it not so strange, as singles they wouldn't try to parse as a tag, they would just be broken XML :neutral:
Sign In or Register to comment.