简体   繁体   中英

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. 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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