Mysql随机生成DataTime类型的数据
随机生成2019年8,9,10月的时间
update table set colum= concat('2019-',floor(8+rand()*3),'-',floor(1+rand()*28),' ', floor(rand()*24),':',floor(rand()*59),':',floor(rand()*59))
随机生成上方数据间隔7天内的时间
update warehousing wa set BufferZDate= (warehousingDate + INTERVAL (concat(floor(rand()*7),' ', floor(rand()*24),':',floor(rand()*59),':',floor(rand()*59))) DAY_SECOND ) where BufferZone='是';
根据操作时间判断操作工人属于哪一个班次(三班倒)
#根据时间判断操作工人属于哪一个班次 update warehousing set ShiftTime= (case when time(WarehousingDate) between '06:00:00' and '13:59:59' then 0 -- 白班 when time(WarehousingDate) between '14:00:00' and '21:59:59' then 1 -- 中班 when ( (time(WarehousingDate) between '22:00:00' and '23:59:59')OR (time(WarehousingDate) between '00:00:00' and '05:59:59') ) then 2 -- 夜班 end)

浙公网安备 33010602011771号