0

I have a query it only show the schedule today my problem is the range of the schedule

datetime_start datetime_end
8/26/22 8/28/22
8/25/22 8/28/22
8/26/22 8/26/22

it will only show this data

datetime_start datetime_end
8/26/22 8/28/22
8/26/22 8/26/22

but i need also to show the 8/25 because it ends on 8/28/22

This is my sample code

SELECT schedule_list.reserved_by, schedule_list.schedule_remarks,
schedule_list.datetime_start, schedule_list.datetime_end, assembly_hall.room_name 
FROM schedule_list  inner join assembly_hall  on assembly_hall.id = schedule_list.assembly_hall_id
                     
WHERE  curdate() between date(datetime_start) AND date(datetime_end) 
and schedule_list.assembly_hall_id=$room_id ORDER BY datetime_start ASC

i dont know what seems to be the problem

2 Answers 2

1

curdate() returns date as 'YYYY-MM-DD' (string) or as YYYYMMDD (numeric)

Please use date_format to change the date format in order to use curdate()

curdate() between DATE_FORMAT(datetime_start, "%Y-%m-%d") AND DATE_FORMAT(datetime_end, "%Y-%m-%d") 
Sign up to request clarification or add additional context in comments.

Comments

0

First check what date return curdate() what I see is when you post it is 8/26/2022 so 8/25/22 is out of range

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.