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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:52:21+00:00 2026-05-18T00:52:21+00:00

When I try to run the following query: … WHERE `date` = DATE_ADD(NOW(), INTERVAL

  • 0

When I try to run the following query:

... WHERE `date` = DATE_ADD(NOW(), INTERVAL 10 HOUR)

It doesn’t work, so I have to use the $date = date("Y-m-d", strtotime('+10 hours'))

But why date_add doesn’t work?

Thanks much

  • 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-18T00:52:21+00:00Added an answer on May 18, 2026 at 12:52 am

    Note that DATE_ADD() function returns a time part in addition to the date. This is not the same as using php’s date("Y-m-d", strtotime('+10 hours')), which only returns the date part.

    SELECT DATE_ADD(NOW(), INTERVAL 10 HOUR);
    +-----------------------------------+
    | DATE_ADD(NOW(), INTERVAL 10 HOUR) |
    +-----------------------------------+
    | 2010-11-05 01:59:51               |
    +-----------------------------------+
    1 row in set (0.00 sec)
    

    You could use WHERE date = DATE(DATE_ADD(NOW(), INTERVAL 10 HOUR)) instead:

    SELECT DATE(DATE_ADD(NOW(), INTERVAL 10 HOUR));
    +-----------------------------------------+
    | DATE(DATE_ADD(NOW(), INTERVAL 10 HOUR)) |
    +-----------------------------------------+
    | 2010-11-05                              |
    +-----------------------------------------+
    1 row in set (0.02 sec)
    

    Test case:

    CREATE TABLE tbl (id int, date datetime);
    
    INSERT INTO tbl VALUES (1, '2010-11-04');
    INSERT INTO tbl VALUES (2, '2010-11-05');
    INSERT INTO tbl VALUES (3, '2010-11-06');
    INSERT INTO tbl VALUES (4, '2010-11-07');
    
    SELECT * FROM tbl WHERE date = DATE(DATE_ADD(NOW(), INTERVAL 10 HOUR));
    +------+---------------------+
    | id   | date                |
    +------+---------------------+
    |    2 | 2010-11-05 00:00:00 |
    +------+---------------------+
    1 row in set (0.00 sec)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly simple query I'm try to write. If I run the
When I try to run the following code (from the REPL) in Clojure: (dotimes
I have installed CherryPy 3.1.0,. Here is what happens when I try to run
I'm trying to run the following MySQL query: mysql> SELECT num.value, agro.mean, agro.dev ->
The following query returns one row as expected when run from phpmyadmin. SELECT units
When I try to run a .NET assembly ( boo.exe ) from a network
Every time I try to run a small application that uses a Derby DB
When I try to run a particular stored procedure on my MS SQL 2005
whenever I try to run something in Java, Eclipse changes into the PHP perspective.
I get a generic failure when I try to run: saslpasswd2 username This was

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.