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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:22:21+00:00 2026-05-26T05:22:21+00:00

I need to get the result from the table, which the date should be

  • 0

I need to get the result from the table, which the date should be difference of 5 from the current date.

ie., specific_date column is present in my table. The format of the date is YYYY-MM-DD.

I need the query something like,

SELECT * FROM `table_name` WHERE DATEDIFF(NOW(), specific_date) < 5
  • 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-26T05:22:22+00:00Added an answer on May 26, 2026 at 5:22 am

    It looks like you are trying to do this:

    WHERE specific_date < (NOW() + 5 days)
    

    First of all, think carefully about the boundary cases. These boundary cases can bite your ankles in SQL. Do you actually want

    WHERE specific_date <= (NOW() + 5 days)
    

    Do your specific_date columns timestamps contain only days (that is dates with times equal to midnight) or do they contain dates and times? If you’re going to get the results you want, you need to be careful about those details.

    At any rate, try this:

    WHERE specific_date <= DATE_ADD(NOW(), INTERVAL 5 DAY)
    

    This is a good way to do such a lookup. The column value stands alone on one side of the inequality predicate (the <=) so mySQL can do an index range scan if you have an index on the column.

    Date arithmetic in MySQL is quite flexible. You can do

       NOW() + INTERVAL 10 SECOND
       NOW() - INTERVAL 2 MINUTE
       NOW() + INTERVAL 4 HOUR
       CURDATE() - INTERVAL 1 WEEK /* midnight one week ago */
       LAST_DAY(NOW()) + INTERVAL 1 DAY - INTERVAL 1 MONTH  /*first day of present month*/
       NOW() - INTERVAL 1 QUARTER
       CURDATE() - INTERVAL 5 YEAR
    

    and so forth.

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

Sidebar

Related Questions

How can I get result from action? I need to show the commentID on
I need to get only 1 record from sql result. we use SELECT TOP
How can I get Google search results from inside a program? I need to
I have a query which I run on a table TXN_DEC(id, resourceid, usersid, date,
Assume I have these tables, from which i need to display search results in
Trying to get a simple COUNT from a table that takes a couple of
I have a table which contains student grades (SAG). I need to show all
I have a table with an event id pk, date column and an event
I run a query and get a result set. I need to get the
I need help getting my headers correct for an azure table storage request from

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.