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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:20:53+00:00 2026-06-16T03:20:53+00:00

I have a MySQL database in which one column is of type DATETIME and

  • 0

I have a MySQL database in which one column is of type DATETIME and stores the values in IST (as my server time zone is IST).

I am getting a two string in EST from the user for which I need to match the date part in my database with that column.

I am using this query :

SELECT * FROM my_table where date(convert_tz(`myDate`,'+05:30','-05:00'))
between  '2012-12-01' and '2012-12-02';

Note: That in my database mysql.time_zone is empty meaning I cannot use strings likeGMTetc in my query, they instructed me to download a package, but I don't want to download it, its fine for me to use00:05` as I will be framing my query in Java.

This query runs fine as I have hardcoded the the time zone offset (for EST.

But I am worried that this query will give wrong data for the dates that fall in Daylight timings i.e. for EDT.

So how do I get the time zone difference (meaning it should return ‘-05:00’ for EST and ‘-04:00 for EDT ) so that I can directly use them when building my query string in java.

My query string may look like :

SELECT * FROM my_table where date(convert_tz(`myDate`,'+05:30','???')) 
between '2012-12-01' and '2012-12-02';

where I want the value at ??? to be dynamically allocated using a prepared statement.

I am using Joda Time API, but don’t have much knowledge of it, whether it has something that can return me the timezone offser for a given timezone string.

  • 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-06-16T03:20:54+00:00Added an answer on June 16, 2026 at 3:20 am

    I would suggest that:

    • You start storing your values as UTC, for the sake of sanity. (The data shouldn’t depend on the server’s location.)
    • You compute the UTC value for the start/end points within Java (using a DateTime set in the right time zone, and then converting to UTC)
    • You pass the UTC start/end directly into the query via SQL parameters (don’t include the values in the SQL text) and avoid the database doing any conversion

    If you really, really can’t change the database to use UTC instead, you should convert your “target timezone” values into IST values instead, and pass those to the database. Again, the query doesn’t need to do conversion: convert your inputs beforehand instead.

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

Sidebar

Related Questions

i have a large mysql database table in which one column contains values ranging
suppose i have one column in mysql database which is stated last time one
I Have MySQL Database in which one of the column contains User Mobile Number.
Hi i have a small query which takes data from one mysql database and
I have a server table which has a column named 'SN' in mysql, when
Database: MySql 5.5.3 I have a type column in table topic , if the
i have a database in MySql that has a name column in it which
I have a database with one column which is labeled as text. I want
I have a MySQL database which contains data i would like to populate into
I currently have a MySQL database which I was hoping to use to store

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.