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

  • Home
  • SEARCH
  • 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 496635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:42:17+00:00 2026-05-13T05:42:17+00:00

Disclaimer: this is needed for an old and ugly codebase that I’d much rather

  • 0

Disclaimer: this is needed for an old and ugly codebase that I’d much rather not touch.

  • There is a table in the database that has a column (among many others) of DATE type.
  • There is a query (auto generated by Torque criteria – don’t ask) with java.util.Date parameter; Torque formats it as full datetime.

So, the query MySQL is getting is something like:

SELECT * FROM my_table
 WHERE my_date = '20091201105320'; // 2009-12-01 10:53:20

The problem is that on one server which has MySQL 5.0.27-standard it works just fine – as in returns all the records from my_table that have my_date set to ‘2009-12-01’. On another server which has MySQL 5.0.45 it does not work. The data is there – if I manually run the query after trimming the time portion out I get correct results back.

The question is:

Is there a setting somewhere, either in MySQL configuration file or in per-session variables (connection string) or somewhere else to force MySQL to ignore the time portion during string constant to date conversion?

I obviously can’t use DATE() function without changing the codebase which I’d much rather not.

  • 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-13T05:42:17+00:00Added an answer on May 13, 2026 at 5:42 am

    Apparently I’m out of luck. From MySQL manual:

    Prior to MySQL 5.0.42, when DATE values are compared with DATETIME values, the time portion of the DATETIME value is ignored, or the comparison could be performed as a string compare. Starting from MySQL
    5.0.42, a DATE value is coerced to the DATETIME type by adding the time portion as '00:00:00'.

    Should anyone find themselves in a similar situation, the only workaround I found was to:

    1. Reset time fields (hours / minutes / seconds) of the java.util.Date instance to zero.
    2. Patch (and I do mean “patch” – there is no way to plug in your own adapter) getDateString() method of Torque’s DB adapter for MySQL (org.apache.torque.adapter.DBMM) to check whether time fields of a date are zeroes and, if so, use “date-only” format.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Disclaimer: This is not actually a programming question, but I feel the audience on
Disclaimer: This is for a homework assignment, but the question is not regarding the
Disclaimer This is not strictly a programming question, but most programmers soon or later
Disclaimer: I realize I can generate this at runtime in Java, this was needed
Disclaimer This question is a repost. I originally asked it here . While there
Disclaimer : this is not a how to question. I would more like to
Disclaimer: This is part of the requirement of the program, so it's not meant
Full disclaimer: I'm a CS student, and this question is related to a recently
Disclaimer: the following is a sin against XML. That's why I'm trying to change
Disclaimer Yes, I am fully aware that what I am asking about is totally

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.