請問各位,我想抓每日 'start_at' 7:50到隔日7:50的資料,有什麼方法可以做到?
start_at 格式 EX:2020-05-21 16:30:28
$sql = "SELECT a.start_at,a.end_at,a.work_no,a.machine_no,
b.groupname,b.arbpl,
FROM machine_time a,machine b
WHERE a.machine_no = b.arbpl and a.work_no like 'C%' and b.groupname !='' ";
這樣直接下where條件應該可以
where a.start_at >= convert(datetime, convert(varchar(4), Year(getdate()))+'/'+convert(varchar(2),Month(getdate()))+'/'+convert(varchar(2),Day(getdate())) + ' 07:50')
and a.start_at <= convert(datetime, convert(varchar(4), Year(getdate()))+'/'+convert(varchar(2),Month(getdate()))+'/'+convert(varchar(2),Day(getdate())+1) + ' 07:50')