vendredi 25 octobre 2019

How can we convert below normal query to Laravel DB or Elequent?

I am trying the get the records that are in between the start and end date based on the current date. I have normal SQL working query and now I am trying it to convert into eloquent query, but I am failing somewhere. Please help me for for this.

BASIC QUERY:

SELECT startDate, endDate FROM YourTable WHERE '2012-10-25' between startDate and endDate

What I had tried:

$q = RoundTable::select(['round_start_date','round_end_date'])->whereBetween('2019-10-25', ['round_start_date', 'round_end_date'])->get();

I got an error as

  Column not found: 1054 Unknown column '2019-10-25' in 'where clause' (SQL: select ` 
   round_start_date`, `round_end_date` from `round_table` where `2019-10-25` between round_start_date 
   and round_end_date`


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire