1

I have read a few different posts on how to filter search results using a custom date field, and on using a range of dates as well. However, I need to filter my results by the native entry_date. I have tried a multitude of things from using date ranges, trying to use exact parameters and more. This is my latest markup:

Search Tag

{exp:low_search:form collection="albums" query="{freebie_3}" result_page="/daily-photos/results/" form_class="internalSearch photoSearch" secure="no"}
      <input type="text" placeholder="MM/DD/YYYY" class="searchDatepicker text search"/>
      <input type="hidden" id="actualDate" name="search:entry_date">
      <button type="submit" class="searchBtn" aria-hidden="true" data-icon="&#xe004;"></button>
{/exp:low_search:form}

Results Tag

{exp:low_search:results  query="{freebie_3}" limit="15" paginate="bottom" paginate_base="/daily-photos/results/"}

Datepicker Javascript

$('.searchDatepicker').datepicker({
        altField: "#actualDate",
        altFormat: "yy-mm-dd 12:00 'PM'",
        dateFormat: "mm/dd/yy", 
        gotoCurrent: true,
        maxDate: "+0d"
 });


You can see where I was trying to resolve a suspected timestamp issue by adding a default timestamp in the javascript. My thinking was to have a default timestamp as shown and then in the search, setting the range for the entry_date to be from yy-mm-dd 12:00 AM to yy-mm-dd 11:00 PM, but I haven't been able to achieve this, and I'm not sure if there's just something basic I am overlooking? I am using Low Search in several other places across the site, so I'd like to be consistent and use it for this scenario. My search results just return all entries with no filtering.

I am running EE 2.5.5 and Low Search 2.2.1. Thanks for looking!

1 Answer 1

0

You'll need to target the native start_on and stop_before parameters to filter entries by Entry Date; check the EE docs here. So, instead of using search:entry_date, use this:

<input type="hidden" id="actualDate" name="start_on">

That will give you all entries with an entry date equal to or greater than the given date. If you want to limit the results to a certain day, you'll also need to define a stop_before field.

2
  • Thanks this works great to get my start date! But I still need to figure a way to get the stop_before. I am dealing with the "time" part of it, which I don't need but is required for native. Do you know if there is a good way to "append" a time to the "start_on" and "stop_before" before it gets submitted to the Low Search? Or would you recommend using javascript to accomplish this?
    – xin
    May 27, 2013 at 14:05
  • You're already using JavaScript for the datepicker, so I'd use JS to generate the start_on and stop_before values as well.
    – Low
    May 28, 2013 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.