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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:19:36+00:00 2026-05-27T09:19:36+00:00

I have saved the dates of a user’s registration as a datetime, so that’s

  • 0

I have saved the dates of a user’s registration as a datetime, so that’s for instance 2011-12-06 10:45:36. I have run this query and I expected this item – 2011-12-06 10:45:36 – will be selected:

SELECT `users`.* FROM `users` WHERE created_at >= '2011-12-01' AND
created_at <= '2011-12-06'

But is not. Exist any elegant way, how to select this item? As a first idea that I got was like 2011-12-06 + 1, but this doesn’t looks very nice.

  • 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-27T09:19:36+00:00Added an answer on May 27, 2026 at 9:19 am

    Your problem is that the short version of dates uses midnight as the default. So your query is actually:

    SELECT users.* FROM users 
    WHERE created_at >= '2011-12-01 00:00:00' 
    AND created_at <= '2011-12-06 00:00:00'
    

    This is why you aren’t seeing the record for 10:45.

    Change it to:

    SELECT users.* FROM users 
    WHERE created_at >= '2011-12-01' 
    AND created_at <= '2011-12-07'
    

    You can also use:

    SELECT users.* from users 
    WHERE created_at >= '2011-12-01' 
    AND created_at <= date_add('2011-12-01', INTERVAL 7 DAY)
    

    Which will select all users in the same interval you are looking for.

    You might also find the BETWEEN operator more readable:

    SELECT users.* from users 
    WHERE created_at BETWEEN('2011-12-01', date_add('2011-12-01', INTERVAL 7 DAY));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written an application that allows a user to create and run a
Suppose, I have saved some permissions in the database by using this code: RoleRepository
I have a NavigatorContent which is displayed when the user selects an item in
I have developed an app that allows the user to fill out text fields
I have this model class User include DataMapper::Resource include BCrypt property :id, Serial property
I have form fields where the user enters in: percents: 50.5% money: $144.99 dates:
I have a need to allow for a user to download an event that
I have a site similar to Expedia and Priceline. The user enters dates and
1] I have the following model: class UserReportedData(db.Model): #country selected by the user, this
I have a form where user enters data about a new inventory item (id,title,

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.