[英]Select all dates between without array
is there any way to display all the dates including weekend and all the dates to start and end Here is the code有没有办法显示所有日期,包括周末和所有开始和结束的日期这是代码
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();
}
Here is the updated query.这是更新的查询。 you need to do something like this你需要做这样的事情
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(`date('yyyy-mm-dd','Checkinout.CheckTime')`, '>', $request->from_date)->where(`date('yyyy-mm-dd','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();
}
}
我已经得到了答案
->whereDate('Checkinout.CheckTime', '>=', $request->from_date)->whereDate('Checkinout.CheckTime', '<=',$request->to_date)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.