0

i need to filter with a date column with not current month records

i tried :

    $start = date('Y-m-d'.' 23:59:59',strtotime('-45 days'));
    $end = date('Y-m-d'.' 00:00:00'); 
    $collection = $collection
                ->addFieldToFilter('created_at',array('from' => $start, 'to' => $end));

this is Showing only Expect the this two month records

but how i can put "Not equal to"

  • What's your goal? – Keyur Shah May 10 at 13:31
  • i won't need this month record how i can filter that??? – prabhakaran7 May 10 at 13:33
  • order colletion ?? – Rk Rathod May 10 at 13:37
  • no custom table – prabhakaran7 May 10 at 13:37
  • check my answer – Rk Rathod May 10 at 13:38
0

Try This :-

$start = date("Y-m-d h:m:s", strtotime(2019-3-1)); //Pass 1st month Starting Date
$end   = date("Y-m-d h:m:s", strtotime(2019-3-29)); //Pass 1st month Ending Date

$collection=$collection->addFieldToFilter('created_at', ['gteq' => $start])
                       ->addFieldToFilter('created_at', ['lteq' => $end]);
  • SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s), query was: SELECT COUNT(*) WHERE (main_table.created_at != '2019-03-26 23:59:59', '2019-05-10 00:00:00' – prabhakaran7 May 10 at 13:41
  • check updated answer – Rk Rathod May 10 at 13:47
  • but showing this month records – prabhakaran7 May 10 at 13:50
  • which record you want to display ??? – Rk Rathod May 10 at 13:51
  • GOAL : I won't need this current month records... – prabhakaran7 May 10 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.