选择没有数组之间的所有日期

有什么方法可以显示所有日期,包括周末和所有开始和结束的日期这是代码


if(request()->ajax())

 {

  if(!empty($request->from_date))

  {



    $data  = DB::table('Checkinout')


            ->join('Z_MemRecord','Checkinout.Userid','=','Z_MemRecord.uid')

            ->select(DB::raw("FORMAT(MIN (Checkinout.CheckTime), 'hh:mm tt') AS Ontime, FORMAT (max(Checkinout.CheckTime), 'hh:mm tt') AS OffTime, Checkinout.Userid,Z_MemRecord.Uname,FORMAT (Checkinout.CheckTime, 'MMM dd yyyy') as dates,FORMAT (Checkinout.CheckTime, 'dddd') as hour"))


              ->where('Checkinout.CheckTime', '>', $request->from_date)->where('Checkinout.CheckTime', '<=', $request->to_date)

            ->groupBy(DB::raw("Convert(Date, Checkinout.CheckTime),Checkinout.Userid,Z_MemRecord.Uname,FORMAT(Checkinout.CheckTime, 'MMM dd yyyy'),FORMAT (Checkinout.CheckTime, 'dddd')"))

            ->orderbyRaw('Convert(Date, Checkinout.CheckTime) desc')


            ->get();        

  }

不显示 2019 年 1 月 10 日。

http://img2.mukewang.com/62da0f250001cf4809410477.jpg

HUWWW
浏览 159回答 2
2回答

慕田峪7331174

这是更新的查询。你需要做这样的事情if(request()->ajax())&nbsp;{&nbsp; if(!empty($request->from_date))&nbsp; {&nbsp; &nbsp; $data&nbsp; = DB::table('Checkinout')&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ->join('Z_MemRecord','Checkinout.Userid','=','Z_MemRecord.uid')&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ->select(DB::raw("FORMAT(MIN (Checkinout.CheckTime), 'hh:mm tt') AS Ontime, FORMAT (max(Checkinout.CheckTime), 'hh:mm tt') AS OffTime, Checkinout.Userid,Z_MemRecord.Uname,FORMAT (Checkinout.CheckTime, 'MMM dd yyyy') as dates,FORMAT (Checkinout.CheckTime, 'dddd') as hour"))&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ->where(`date('yyyy-mm-dd','Checkinout.CheckTime')`, '>', $request->from_date)->where(`date('yyyy-mm-dd','Checkinout.CheckTime')`, '<=', $request->to_date)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ->groupBy(DB::raw("Convert(Date, Checkinout.CheckTime),Checkinout.Userid,Z_MemRecord.Uname,FORMAT(Checkinout.CheckTime, 'MMM dd yyyy'),FORMAT (Checkinout.CheckTime, 'dddd')"))&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ->orderbyRaw('Convert(Date, Checkinout.CheckTime) desc')&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ->get();&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp;

呼啦一阵风

我已经得到了答案->whereDate('Checkinout.CheckTime',&nbsp;'>=',&nbsp;$request->from_date)->whereDate('Checkinout.CheckTime',&nbsp;'<=',$request->to_date)
打开App,查看更多内容
随时随地看视频慕课网APP