List Info

Thread: Not able to Compare date values using Criteria




Not able to Compare date values using Criteria
user name
2006-09-11 07:32:04
Hello Friends

SimpleDateFormat frmt = new
SimpleDateFormat("yyyy-MM-dd");
				searchCrit.add(Restrictions.le("postingDate"
,
java.sql.Date.valueOf(new String(frmt.format(dt)))));
				searchCrit.add(Restrictions.ge("postingDate"
,
java.sql.Date.valueOf(new String(frmt.format(newDt)))));

I am using this query to compare betwwen two date values.In
data base i
have stored the date as java.sql.Date ftype.Now while
comparing it
takes the argument in this format:

                dt as:  11 August 2006

Now in database it is stored as 2006-08-11.So its not able
to fetch the
desired results.So how to modify it..Please help..
Thanks In advance.
Sushovan


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "java and hibernate" group.
To post to this group, send email to java-and-hibernategooglegroups.com
To unsubscribe from this group, send email to
java-and-hibernate-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/java-and-hibernate
-~----------~----~----~----~------~----~------~--~---

Not able to Compare date values using Criteria
user name
2006-09-13 05:04:34
 use Expression.between for this purpose
--

Shahzad Raja

Software Engineer
IAC Islamabad
0300-5335771
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "java and hibernate" group.
To post to this group, send email to java-and-hibernategooglegroups.com
To unsubscribe from this group, send email to java-and-hibernate-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/java-and-hibernate
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )