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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:50:23+00:00 2026-05-10T21:50:23+00:00

I have a MySQL (v 5, MyISAM) query that returns different rows depending on

  • 0

I have a MySQL (v 5, MyISAM) query that returns different rows depending on date string format.

(1) IFNULL(date1, ADDDATE('2008/10/31 23:59:59',INTERVAL 1 DAY)) > '2008-10-31 23:59:59' (2) IFNULL(date1, ADDDATE('2008/10/31 23:59:59',INTERVAL 1 DAY)) > '2008/10/31 23:59:59'  (3) date1 > '2008-10-31 23:59:59' (4) date1 > '2008/10/31 23:59:59' 

‘/’ vs ‘-‘ on RHS of ‘>’ comparisson operator.

(1) 75,098 rows *expected* (2) 0 rows *DIFFERENCE* (3) 199 rows *simple case as expected* (4) 199 rows *simple case as expected* 

Question – Why ?

  • 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. 2026-05-10T21:50:23+00:00Added an answer on May 10, 2026 at 9:50 pm

    Short answer: Use CAST(... AS DATE)

    Long answer:

    From MySQL DATE type:

    A “relaxed” syntax is allowed: Any punctuation character may be used as the delimiter between date parts or time parts. For example, ’98-12-31 11:30:45′, ‘98.12.31 11+30+45′, ’98/12/31 11*30*45′, and ’98@12@31 11^30^45’ are equivalent.

    In your examples 1 and 2 you’re using ADDDATE… this will always return a date with a ‘-‘ separator, no matter what the input format:

    +-----------------------------------------------+ | ADDDATE('2008/10/31 23:59:59',INTERVAL 1 DAY) | +-----------------------------------------------+ | 2008-11-01 23:59:59                           | +-----------------------------------------------+ 

    You’re also using IFNULL, which loses the type information, so when you compare this it’s comparing as strings.

    What you can do is cast this back to a date:

    mysql> SELECT IFNULL(null, ADDDATE('2008/10/31 23:59:59',INTERVAL 1 DAY)) > '2008/10/31 23:59:59'; +-------------------------------------------------------------------------------------+ | IFNULL(null, ADDDATE('2008/10/31 23:59:59',INTERVAL 1 DAY)) > '2008/10/31 23:59:59' | +-------------------------------------------------------------------------------------+ |                                                                                   0 | +-------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)   mysql> SELECT CAST(IFNULL(null, ADDDATE('2008/10/31 23:59:59',INTERVAL 1 DAY)) AS DATE) > '2008/10/31 23:59:59'; +---------------------------------------------------------------------------------------------------+ | CAST(IFNULL(null, ADDDATE('2008/10/31 23:59:59',INTERVAL 1 DAY)) AS DATE) > '2008/10/31 23:59:59' | +---------------------------------------------------------------------------------------------------+ |                                                                                                 1 | +---------------------------------------------------------------------------------------------------+ 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say you have a MySQL 5.0 MyISAM table with 100 million rows, with one
I have an older web application that uses a MySQL Database (MYISAM). I noticed
I have mysql table that has a column that stores xml as a string.
I have a large mysql MyISAM table with 1.5mil rows and 4.5GB big, still
We have a MyISAM table with approximately 75 milion rows that has 5 columns:
I have MySQL running such that I can open a client command line and
I need to have MySQL query like this one: UPDATE table_name SET 1 =
I have the following MySQL query: SELECT value_1, ( SELECT value_4 FROM table_1 WHERE
I have a query on my homepage that is getting slower and slower as
My MysQL database contains multiple MyISAM tables, with each table containing millions of rows.

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.