3 years ago

where condition to get pass 30 days worth of records

Posted 3 years ago by sanainfotech


I have a date column in the database with varchar datatype stored as d-m-Y. In my where condition I am trying to fetch records for past 30 days only.

$backdate = Carbon::parse('-30 days')->toDateString(); $date30DaysBack = Carbon::parse($backdate)->format('d-m-Y'); $adverts = DB::table('adverts') ->where(DB::raw('STR_TO_DATE(,"%d-%m-%Y")'), '>=',$date30DaysBack)

Please sign in or create an account to participate in this conversation.