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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:51:43+00:00 2026-06-12T07:51:43+00:00

I want to fetch records that fall between the two timestamp. I want this

  • 0

I want to fetch records that fall between the two timestamp. I want this using hibernate. I tried it doing with the below query but I am not getting any output


HQL = "From AddressInfo address where address.addressId = '"+newValues.get("pickupAddress").toString()+"' and address.updatedDateAndTime between date_format('" + DateUtility.getTimeOfBeforeOneMinute() + "', '%m/%d/%y %H:%i:%s') and date_format('"+DateUtility.getCurrentDate()+"','%m/%d/%y %H:%i:%s')";

This is the SQL Query formed from the console :


select addressinf0_.T_ADM_NPK_ADDRESS_ID as T1_5_, addressinf0_.T_ADM_VNM_USER_ID as T2_5_, addressinf0_.T_ADM_FPK_USER_ASSIGNED_ID as T3_5_, addressinf0_.T_ADM_VNM_STREET_1 as T4_5_, addressinf0_.T_ADM_VNM_STREET_2 as T5_5_, addressinf0_.T_ADM_VNM_STREET_3 as T6_5_, addressinf0_.T_ADM_VNM_CITY as T7_5_, addressinf0_.T_ADM_VNM_STATE as T8_5_, addressinf0_.T_ADM_VNM_ZIPCODE as T9_5_, addressinf0_.T_ADM_DNM_LATITUDE as T10_5_, addressinf0_.T_ADM_DNM_LONGITUDE as T11_5_, addressinf0_.T_ADM_TNM_CREATE_DATETIME as T12_5_, addressinf0_.T_ADM_TNM_UPDATE_DATETIME as T13_5_ from t_address_master addressinf0_ where addressinf0_.T_ADM_NPK_ADDRESS_ID='19' and (addressinf0_.T_ADM_TNM_UPDATE_DATETIME between date_format('Tue Oct 02 17:09:53 EDT 2012', '%m/%d/%y %H:%i:%s') and date_format('Tue Oct 02 17:10:53 EDT 2012', '%m/%d/%y %H:%i:%s'))

My DB has a record with T_ADM_TNM_UPDATE_DATETIME = 10/2/2012 5:10:40 PM

But the resultset is not able to fetch this query…I don’t know wwhere I am going wrong.

Can anyone please guide me further

  • 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-12T07:51:44+00:00Added an answer on June 12, 2026 at 7:51 am

    You should be using HQL parameters instead of concatenate.

    Take this example:

    Map<String, Object> parameterNameAndValues = new HashMap<String, Object>();
    
    Date startDate;
    Date endDate;
    
    // Assign values to startDate and endDate
    
    parameterNameAndValues.put("startDate", startDate);
    parameterNameAndValues.put("endDate", endDate);
    
    String hqlQuery = "FROM EntityName WHERE fechaInicio BETWEEN :startDate AND :endDate";
    
    Query query = this.sessionFactory.getCurrentSession().createQuery(hqlQuery);
    
    for (Entry<String, Object> e : parameterNameAndValues.entrySet()) {
        query.setParameter(e.getKey(), e.getValue());
    }
    
    return query.list();
    

    This will bind the date parameters and hibernate will make the necessary convertions for you avoiding sanity checks and errors. Remember that even if MySQL saves Date objects in that format other databases may not and it will undermine Hibernate help.

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

Sidebar

Related Questions

I want to fetch the unmatching records from two table in SQL, the table
I want fetch last record using hibernate criteria Can u help me?
i Want to fetch this data using json decode. Please Help.. So far i
I want to fetch all the records that have null in openingbalance field of
I am trying to fetch the hotels records from database.I used below query and
I have two tables that I want to fetch data from. Lets call them
My table has records for every minute, now I want to fetch records with
I want to fetch the title of a webpage which I open using urllib2.
I want to fetch a method's comments,take below method for example: /** * Returns
I want to fetch 50 random records without duplication. Table Name : table 1

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.