6

i have a date field in my database which has datetype as data type, how can i use active record to fetch data according to specific date range?

$model = ModelName::find()
        ->where(["date"=>"FROM '2015-06-21' TO '2015-06-27' ", "status"=>1])->all();
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
Pingu Kutu
  • 357
  • 2
  • 5
  • 11

1 Answers1

21

I think the correct way could be this:

$model = ModelName::find()->where(['between', 'date', "2015-06-21", "2015-06-27" ])
->andWhere(['status'=> 1])->all();
Code Prank
  • 4,209
  • 5
  • 31
  • 47
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
  • @priyankaahire post a new question with your code and a clear explanation fo your problem .. and comment me the link for your question .. if i'm free i take a look – ScaisEdge Sep 03 '16 at 15:40
  • http://stackoverflow.com/questions/39318434/ho-to-write-between-query-in-yii2...This is a link Where I am adding new question – Priyanka Ahire Sep 04 '16 at 15:19