简体   繁体   English

今天的日期是否与数据库PHP / MYSQL中的现有范围相交

[英]Does today's date intersect existing ranges in database PHP/MYSQL

I'm creating a time off requester for my business and I think I've run into a small issue. 我正在为我的业务创建一个请求者的时间,我想我遇到了一个小问题。

Goal: I want to display a page that will show me if anyone has request the current day off. 目标:我想显示一个页面,告诉我是否有人要求当天休息。

Problem: I have the date_from and date_to fields which contain the information of the start and end dates for each request off. 问题:我有date_from和date_to字段,其中包含每个请求关闭的开始和结束日期的信息。 However, and I apologize if I'm just over thinking (under thinking?) the solution, but I cannot for the life of me figure out how to compare if today's current date (yyyy-mm-dd) intersects with any of the current records in my database. 但是,如果我只是思考(在思考?)解决方案,我道歉,但我不能为我的生活找出如何比较今天的当前日期(yyyy-mm-dd)是否与当前任何一个相交我的数据库中的记录。 I've tried toying around with the between query but haven't had much luck. 我试过在查询之间玩弄,但没有多少运气。

Any assistance would be greatly appreciated! 任何帮助将不胜感激!

SELECT * FROM TheTable
WHERE CURDATE() BETWEEN date_from AND date_to

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM