Wednesday, February 29, 2012

Re: Find condition on Date field

Found the solution, not sure if it is the Cake way of doing it but it
works.
$conditions = array('YEAR(MonthlyReturn.month)' => $sel_year); <---
match by year only
$conditions = array('MONTH(MonthlyReturn.month)' => $sel_month); <---
match by month only

On Feb 29, 10:32 am, Kro <yenohamonin...@gmail.com> wrote:
> 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 aDATEfield
>
> I tried $conditions = array('MonthlyReturn.month.YEAR' => $sel_year);
>
> Is it possible to add aconditionwhich 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