Wednesday, February 29, 2012

Find condition on Date field

Hi,
I am trying to filter a VIEW by month and year using separate drop
lists. My code works fine if a year and month selection is made but I
want to be able to filter based on a selection in either one, i.e. not
force a selection of both.
As it stands I am concatenating the year and month selections (day is
always 01) as follows:

$sel_date = $sel_year.'-'.$sel_month.'-01';
$conditions = array('MonthlyReturn.month' => $sel_date); <---note
MonthlyReturn.month is actually a DATE field

I tried $conditions = array('MonthlyReturn.month.YEAR' => $sel_year);

Is it possible to add a condition which only searches by either month
or year?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate