Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7736237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:41:44+00:00 2026-06-01T07:41:44+00:00

I have a mysql database with a table structure like below : Table Name

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:41:45+00:00Added an answer on June 1, 2026 at 7:41 am

    Try below :

    select shop_name,if(left(curtime(),5) between start_time  and close_time ,'Open','Closed') as status 
    from tablename
    

    Assuming you storing star_time and close_time in 18:30,16:15 … Format.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have a MySQL database with the following table structure: TransactionType : Transaction_Amount, Transaction_ID,
I have something like Facebook's Wall build on PHP that uses MySQL database. Structure:
I have a MySQL database and would like to have a similar structure in
I have a table in a MySQL Database which has this structure: CREATE TABLE
i have a large mysql database table in which one column contains values ranging
I have a MySQL database with a fairly large table where the products are.
So I have a mySQL database with a 'users' table which includes a username,
I have a MySQL database, and a particular table in that database will need
I have 2 tables in my mysql database: CREATE TABLE IF NOT EXISTS `RECIPES`

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.