本文介绍了检查给定的时间是否介于两个时间(小时,分钟)格式之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 MySQL 中有接下来的 6 个字段.
I have next 6 fields in MySQL.
TIME_RIGHT_NOW_HOUR (INT)
TIME_RIGHT_NOW_MINUTE (INT)
TIME_WORKING_FROM_HOUR (INT)
TIME_WORKING_FROM_MINUTE (INT)
TIME_WORKING_TO_HOUR (INT)
TIME_WORKING_TO_MINUTE (INT)
小时和分钟采用 24 时间格式.
Hour and minutes are in 24 time format.
我需要检查现在是两个工作时间之间的时间.例如,如果 TIME_RIGHT_NOW_HOUR 是 15 并且 TIME_RIGHT_NOW_MINUTE 是 30 -> 15:30是在 TIME_WORKING_FROM_HOUR 10、TIME_WORKING_FROM_MINUTE 15 之间10:15 和 TIME_WORKING_TO_HOUR 18,TIME_WORKING_TO_MINUTE 20 -> 18:20
I need to check is the right now time between two working times.for example if TIME_RIGHT_NOW_HOUR is 15 and TIME_RIGHT_NOW_MINUTE is 30 -> 15:30is it between TIME_WORKING_FROM_HOUR 10, TIME_WORKING_FROM_MINUTE 1510:15 and TIME_WORKING_TO_HOUR 18, TIME_WORKING_TO_MINUTE 20 -> 18:20
推荐答案
也许 maketime() 正是您要寻找的.p>
Perhaps maketime() is what you are seeking.
SELECT 1
FROM table
WHERE
MAKETIME(TIME_RIGHT_NOW_HOUR,TIME_RIGHT_NOW_MINUTE,0)
BETWEEN MAKETIME(TIME_WORKING_FROM_HOUR,TIME_WORKING_FROM_MINUTE,0)
AND MAKETIME(TIME_WORKING_TO_HOUR,TIME_WORKING_TO_MINUTE,0);
这篇关于检查给定的时间是否介于两个时间(小时,分钟)格式之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!