现在有这么一个表,我想要实现,穿一个时间参数进去,返回对应的班次及时间。 例如:2023.11.25 20:28:20。班次:白班 ,日期:2023.11.25 例如:2023.11.25 07:45:20。班次:夜班 ,日期:2023.11.24 我的条件改怎么写呢? 这是我目前的写法,还是有点问题 DECLARE @DATE DATETIME = '2023-11-22 07:31:20.433' SELECT TOP 100 * FROM worktime AS wkt WHERE wkt.IsCheck = 'Y' AND wkt.companyid = 'DGXY' AND 'XPREPRT' = wkt.dept AND (CONVERT(TIME,@DATE) BETWEEN CONVERT(TIME,wkt.time1) AND CONVERT(TIME,wkt.time6) OR (CONVERT(TIME,@DATE) BETWEEN CONVERT(TIME,wkt.time1) AND CONVERT(TIME,CONVERT(VARCHAR(10),@DATE,23)+' 23:59:59') OR CONVERT(TIME,@DATE) BETWEEN CONVERT(TIME,CONVERT(VARCHAR(10),@DATE,23)+' 00:00:00') AND CONVERT(TIME,wkt.time6) ) ) |