mardi 2 février 2021

check the date field value 'month and year' is in given date

I have tow tables meeting_dump and prospects_audit table

I want to get the value meeting id for the prospects based on prospects id.I want to check 3 conditions in query

  1. meeting_dump.date_start start date month is in two given months ($dates_between=['2021-02-01','2021-02-02']) if I give 2021-02-01 I want to check the meeting_dump.date_start is in 2021-02 and get the parent_id

2.after_value string should be MGl 3.meeting_dump.status.status should be 'Held'

my query is

$type='prospects';
$meeting_ids=DB::table($type.'_audit_dump')->leftJoin('meeting_dump','meeting_dump.parent_id',$type.'_audit_dump.parent_id')->where('field_name','=','lead_stage_c')
                 ->where(function ($query) use ($dates_between){
            return $query->orWhere(DB::raw(date('m',strtotime('meeting_dump.date_start'))),'=',date("m", strtotime($dates_between[0])))->orWhere(DB::raw(date('m',(strtotime('meeting_dump.date_start')))),'=',date("m", strtotime($dates_between[1])));
             })
             ->where('after_value_string','=','MGL')->where('meeting_dump.status','Held')->pluck($type.'_audit_dump.parent_id')->toArray();

dd ::getQueryLog() displays

select "prospects_audit_dump"."parent_id" from "prospects_audit_dump" left join "meeting_dump" on "meeting_dump"."parent_id" = "prospects_audit_dump"."parent_id" where (02 = 02 or 02 = 02) and "after_value_string" = 'MGL' and field_name='lead_stage_c' and "meeting_dump"."status" = 'Held';

and getting wrong data

how to check the month of the date start is in give date



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire