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 948679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:16:55+00:00 2026-05-15T23:16:55+00:00

Can anyone help me on how did MySQL can’t read a rows of I’ve

  • 0

Can anyone help me on how did MySQL can’t read a rows of I’ve try to execute this query.

SELECT * FROM attendance where '2010-07-13 00:06:00' BETWEEN timein AND timeout;

This is the date in the table:

+-----------------------+-----------------------+
|  timein               |  timeout              |
------------------------+------------------------
|  2010-07-13 23:44:11  |  2010-07-14 08:01:14  |
|  2010-07-12 23:40:56  |  2010-07-13 08:00:52  |   
|  2010-07-10 05:49:32  |  2010-07-10 14:00:45  |
+-----------------------+-----------------------+

as we can see on the table, row 2 is expected to meet the date validation but when I execute the query, it returns no result. Can anyone help if there was an alternative queries to do it.

  • 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-05-15T23:16:55+00:00Added an answer on May 15, 2026 at 11:16 pm

    Your query is fine. It should work as expected:

    CREATE TABLE attendance (id int, timein datetime, timeout datetime);
    
    INSERT INTO attendance VALUES (1, '2010-07-13 23:44:11', '2010-07-14 08:01:14');
    INSERT INTO attendance VALUES (2, '2010-07-12 23:40:56', '2010-07-13 08:00:52');
    INSERT INTO attendance VALUES (3, '2010-07-10 05:49:32',' 2010-07-10 14:00:45');
    
    SELECT * FROM attendance where '2010-07-13 00:06:00' BETWEEN timein AND timeout;
    +------+---------------------+---------------------+
    | id   | timein              | timeout             |
    +------+---------------------+---------------------+
    |    2 | 2010-07-12 23:40:56 | 2010-07-13 08:00:52 |
    +------+---------------------+---------------------+
    1 row in set (0.01 sec)
    

    Are you sure that your timein and timeout fields are of type datetime or timestamp?


    UPDATE: Further to @Psytronic’s suggestion the comments below, your example would even work if your fields were of varchar type:

    CREATE TABLE attendance (id int, timein varchar(100), timeout varchar(100));
    
    INSERT INTO attendance VALUES (1, '2010-07-13 23:44:11', '2010-07-14 08:01:14');
    INSERT INTO attendance VALUES (2, '2010-07-12 23:40:56', '2010-07-13 08:00:52');
    INSERT INTO attendance VALUES (3, '2010-07-10 05:49:32',' 2010-07-10 14:00:45');
    
    SELECT * FROM attendance where '2010-07-13 00:06:00' BETWEEN timein AND timeout;
    +------+---------------------+---------------------+
    | id   | timein              | timeout             |
    +------+---------------------+---------------------+
    |    2 | 2010-07-12 23:40:56 | 2010-07-13 08:00:52 |
    +------+---------------------+---------------------+
    1 row in set (0.00 sec)
    

    However your fields should not be varchar, as the above would be doing a string comparison instead of a time comparison.

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

Sidebar

Related Questions

I did this but it didn't work. Can anyone help me? Thanks. $('.current_element').mouseover(function() {
Can anyone help - this is driving me mad. I am calling a mysql
Can anyone help or provide me with some suggestions for the below query. I
Can anyone help me with this? I have this function in a singleton class.
Can anyone help me with this? I have not been able to find anything
I cannot figure out why this code will not work. Can anyone help? I
I did some googling, and came to the script below, Can anyone help /me
Can anyone help me on my query. I have a page which has a
Hoping someone can help me with this: I have a rather long query (about
Can Anyone help me why x2 prints zero. I guess because of floating point

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.