Solved

Looking for an HQL Query to parse Calendar Date

Posted on 2011-09-06
5
745 Views
Last Modified: 2012-05-12
Hi - I need a hibernate HQL query which can parse a calendar date in a database field and extract (a) the calendar year from the date( or timestamp) and also (b) the calendar month from the date( or timestamp). The purpose is to retrieve a set of entries by year or by month

Thanks

0
Comment
Question by:abuyusuf35
  • 2
  • 2
5 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36502716
check this link
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html#queryhql-expressions

these functions are only supported if the underlying database is supporting the same, which is one of the cool things about HQL. If Hibernate doesn't understand a particular syntax, say a call to sysdate() or your adddate function that is in SQL, then it just passes the text to the database. Meaning if the database suports those functions it will work. So it means that your HQL query doesn't have to always have just HQL, but some SQL can work
0
 

Accepted Solution

by:
abuyusuf35 earned 0 total points
ID: 36516345
I found a solution to my question - select * from Holiday c where c.holidayDate between :start and :end
0
 

Author Comment

by:abuyusuf35
ID: 36516403
I've requested that this question be closed as follows:

Accepted answer: 0 points for abuyusuf35's comment http:/Q_27293994.html#36516345

for the following reason:

I found a solution elsewhere
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36516404
this solution is mentioned in the link
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java Jpanels and Jframe 8 33
MySQL  on Tomcat 8 45
Configure a Bean in an XML file 4 31
hibernate example using maven 12 42
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question