alvin567 Posted May 27, 2012 Share Posted May 27, 2012 $conditions['Claim.created <= '] = date('Y-m-d', $m2); lets say I have two date,$m1 and $m2,how do I set the condition to be between the date? Quote Link to comment https://forums.phpfreaks.com/topic/263206-cakephp-between-date-condition/ Share on other sites More sharing options...
jcombs_31 Posted May 27, 2012 Share Posted May 27, 2012 Use between. http://book.cakephp.org/1.3/en/view/1030/Complex-Find-Conditions Quote Link to comment https://forums.phpfreaks.com/topic/263206-cakephp-between-date-condition/#findComment-1348996 Share on other sites More sharing options...
alvin567 Posted May 28, 2012 Author Share Posted May 28, 2012 Great!! $conditions = array( 'Renewal.year' => $renewal_period, 'Renewal.void' => 0, 'Renewal.approved' => 3, 'Claim.void' => 0, 'Claim.draft' => 0 ); Can I do this? array_push($conditions, array('Claim.created BETWEEN ? and ?' => array(strtotime($start), strtotime($end)))); Quote Link to comment https://forums.phpfreaks.com/topic/263206-cakephp-between-date-condition/#findComment-1349101 Share on other sites More sharing options...
alvin567 Posted May 28, 2012 Author Share Posted May 28, 2012 On top of that I have this error? Warning (2): mssql_query() [function.mssql-query]: message: Conversion failed when converting date and/or time from character string. (severity 16) [CORE/cake-1.2.6/libs/model/datasources/dbo/dbo_mssql.php, line 181] Warning (2): mssql_query() [function.mssql-query]: General SQL Server error: Check messages from the SQL Server. (severity 5) [CORE/cake-1.2.6/libs/model/datasources/dbo/dbo_mssql.php, line 181] Warning (512): SQL Error: Conversion failed when converting date and/or time from character string. [CORE/cake-1.2.6/libs/model/datasources/dbo_source.php, lin Quote Link to comment https://forums.phpfreaks.com/topic/263206-cakephp-between-date-condition/#findComment-1349103 Share on other sites More sharing options...
alvin567 Posted June 5, 2012 Author Share Posted June 5, 2012 array_push($conditions,array('Claim.created BETWEEN ? and ?' => array($startdate, $enddate))); there seems to be an error how do I go about it? Quote Link to comment https://forums.phpfreaks.com/topic/263206-cakephp-between-date-condition/#findComment-1351316 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.