Comparison of dates in hibernate

Source: Internet
Author: User

Ext.: http://crazycat03.iteye.com/blog/252784

Today encountered in HQL to select the time period of the data, time compared to a problem, through the Internet search and practice, summarized as follows:
String begindate = Request.getparameter ("Begindate");
String EndDate = Request.getparameter ("EndDate");
The above two data are obtained from the page and are of type string
HQL = "From A as model";
HQL + = "where model.proid= '" + "556655" + "'";
if (! Strutil.isblank (begindate)) {
HQL + = "and Model.signtime>=to_date ('" + begindate + "', ' yyyy-mm-dd HH:mi:ss ')";
}
if (! Strutil.isblank (EndDate)) {
HQL + = "and Model.signtime<=to_date ('" + EndDate + "', ' yyyy-mm-dd HH:mi:ss ')";
}
Or you can directly use between ... to ...
Just start, enter a, compare once no problem, but two data at the same time compare error, later in the client test, found that two less ' (single quotation marks), plus on the good, hehe, posted out, afraid of someone and I made the same mistake

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.