I have a query
select userid from userinfo where DATEDIFF(ExpiryDate,curdate())<100;
how can this query be executed using hibernate??
I have tried this
List<String> usernames = (List<String>)(getSession().createQuery("select userid from userinfo where DATEDIFF(ExpiryDate,CURRENT_DATE)<100;").list());
for (Iterator iterator = usernames.iterator(); iterator.hasNext();){
String username= (String) iterator.next();
System.out.println(username);
}
But this does'nt return any result is there any other way to do this??
DATEDIFF(ExpiryDate,CURRENT_DATE)toDATEDIFF(ExpiryDate,now())and see if this worksselect userid from userinfo where DATEDIFF(ExpiryDate,now()) < 100 ;it should work.