All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Matrix Date Search

ciaran 24 Apr 2014 08:42 question, complete

Hi
I need to implement the following search on my ee site

I have a matrix field with the following columns

start date
end date

for example I have an entry with 2 rows in my matrix column where the values listed are dates that are not available

Entry Title: Entry 1

Matrix values
Start Date End Date
01/01/2014 15/01/2014
01/02/2014 20/02/2014

On my search form I have a search form with start date and end date

The user searches with the the following details
Start Date End Date
02/01/2014 10/01/2014

When the users searches no results are displayed as the dates the user selected are in the matrix field as not available

The user searches with the the following details
Start Date End Date
16/01/2014 20/01/2014

Entry 1 is returned as the dates selected are not in the unavailable list for that entry

Is this possible with low search and is there an example?

Thanks

Replies

  1. Low 24 Apr 2014 11:31

    This depends entirely on how the dates in Matrix are stored. I presume they are stored as timestamps. Only non-Matrix/Grid date fields values are converted to timestamps when searching, so you'll need to convert the search values to timestamps themselves.

    Then you'll need to figure out what the search actually does. I guess it's like
    this:

    - Matrix start date = Given end date

    The Ranges filter doesn't support targeting Matrix columns, so you'll have to use the Field Search filter. Something like

    - search:matrix_field:start_date="=6789"

    Where the 12345 and 6789 values are timestamps you've created beforehand.