We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43344
    • 1 Posts
    Hi Guys,

    I need a little help with modx xPDO my code below is already working for startdate. I'm not just sure on how to add enddate filter.
            $startdate = '2013-08-28';
    	$enddate = '2013-09-11';
    	$c = $modx->newQuery('modResource');
    	$c->innerJoin('modTemplateVarResource','TemplateVarResources');
    	$c->innerJoin('modTemplateVar','TemplateVar','`TemplateVar`.`id` = `TemplateVarResources`.`tmplvarid` AND `TemplateVar`.`name` = "eventstart"');
    	
    	$c->where(array(
    	    'parent:IN' => array(173),
    	    'deleted' => 0,
    	    'hidemenu' => 1,
    	    'TemplateVarResources.value:>=' => $startdate,
    	));
    
    	$c->sortby('`TemplateVarResources`.`value`','ASC');
    	$resources = $modx->getCollection('modResource',$c);
    


    Any suggestions will be greatly appreciated.

      • 42602
      • 81 Posts
      A simple answer right now with the current xPDO version is to modify tge
      'TemplateVarResources.value:>=' => $startdate,
      to
      'TemplateVarResources.value BETWEEN ' . $startdate . ' AND ' . $enddate
      


      Basic SQL, but right at the moment xPDO does not have function shortcuts for it. [ed. note: dunnock last edited this post 13 years, 5 months ago.]