I have a mysql database with a table structure like below :
Table Name : shop_mst
Fields :
shop_name varchar(100)
start_time time
close_time time
Time is stored in 24Hour format. Now I want to create a sql query to display all the records but show Shop status as Open/Closed based on current time. So if the current time comes in between start_time & close_time, then it should show “Open” with Shop name. And if it is not, it should show “Closed” with Shop name. How can I do that? I also want to compare Day with a field in another table but that part I will do myself 🙂
Thanks in advance.
Try below :
Assuming you storing star_time and close_time in 18:30,16:15 … Format.