ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Can't get channel:entries for a date range

December 25, 2011 8:20am

Subscribe [2]
  • #1 / Dec 25, 2011 8:20am

    GDmac - expocom

    350 posts

    I’m having problems with the start_on= and stop_before= parameters.
    Or actually, with selecting entries inside a particular date range.

    For instance, i want to select entries that are open in december:
    start_on=“2011-12-01 00:00”  stop_before=“2011-12-31 23:59”
    (of course show_future_entries=“yes” and show_expired=“yes” are in place)

    What happens is, an entry that starts on november 20th and expires on
    december 5th is not shown in the december date range, even though it is not expired.

    It seems, non-expired entries, from before start_on=, are not included in the mix.

  • #2 / Dec 25, 2011 8:40am

    GDmac - expocom

    350 posts

    Proposal, include an open_on= parameter which also checks if an entry is not expired on the start date.

    In mod.channel.php, method build_sql_query, modify the date-range code to include an open_on parameter

    /**------------
      /**  Limit query by date range given in tag parameters
      /**------------*/
      if ($this->EE->TMPL->fetch_param('start_on'))
      {
       $sql .= "AND t.entry_date >= '".$this->EE->localize->convert_human_date_to_gmt($this->EE->TMPL->fetch_param('start_on'))."' ";   
      }
    
      if ($this->EE->TMPL->fetch_param('open_on'))
      {
       $open_on = $this->EE->localize->convert_human_date_to_gmt($this->EE->TMPL->fetch_param('open_on'));
       
       $sql .= "AND (t.entry_date >= '$open_on' OR (t.entry_date <= '$open_on' AND t.expiration_date >= '$open_on')) ";   
      }
    
    
      if ($this->EE->TMPL->fetch_param('stop_before'))
      {
       $sql .= "AND t.entry_date < '".$this->EE->localize->convert_human_date_to_gmt($this->EE->TMPL->fetch_param('stop_before'))."' "; 
      }

    either use start_on= to get entries that start on a particular date, or open_on= to get entries that are not expired on a particular date.

  • #3 / Dec 27, 2011 12:26pm

    Kyle Cotter

    730 posts

    Hey GDmac - expocom,

    The outcome you explained above is in fact the expected behavior that is to occur.

    If the “start_on” is set to December 1st, it wouldn’t pick up on entries from November, even if the entry hasn’t expired yet.

    The proposal you made would certainly be a good feature request.

    Is there anything else I can help you with?

    Thanks!

  • #4 / Jan 18, 2012 4:44pm

    GDmac - expocom

    350 posts

    Note: feature request posted, this support thread can be closed.
    http://ellislab.com/forums/viewthread/207622/

  • #5 / Jan 18, 2012 4:55pm

    Kyle Cotter

    730 posts

    Thanks GDmac - expocom!

    If you have any more questions, feel free to start a new thread.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases