Yes i tries ld that one. But its still diplays older than 5 days.My context is 
something different. I  don't want to use the range b/w two dates
        Here is my scenario, I want to retrieve all the the ticket bookings 
which are  starts from currentdate-5  and Bookings can be any date in future. 
     As I said previously, in db schema the type is date but in jpa entities 
it's timestamp. Since date in SQL can store the time format like 2011-04-12 
0:12:23 so we have kept in as date in db schema  and to store in this format we 
are using @temporal.type timestamp we r using
   

> Query q = em.createQuery("Select m from Message m "
>    + "where m.targetTime > :fivedays

        
Sent from my iPhone

On May 5, 2011, at 6:19 PM, Rick Curtis <[email protected]> wrote:

> Did you try Mike's answer?
> 
> Date now = new Date();
> Date thirtyDaysAgo = new Date(now.getTime() - (30 * MS_IN_DAY));
> 
> Query q = em.createQuery("Select m from Message m "
>    + "where m.targetTime < :now and m.targetTime > :thirtyDays");
> q.setParameter("now", now);
> q.setParameter("thirtyDays", thirtyDaysAgo);
> 
> List<Message> results = (List<Message>) q.getResultList();
> 
> 
> 
> On Thu, May 5, 2011 at 4:35 PM, ram <[email protected]> wrote:
> 
>> Hi,
>>  I am trying to implement sysdate-5 in jpa.
>> 
>> select *From emp where joinDate > sysdate-5
>> 
>>       The problem is in db schema, join date is defined as date, but in
>> jpa entites, we have made it as TimeStamp by using @temporal so the it can
>> store exact timestamp.
>> 
>>     when i tried to query by using @namedQuery, i am getting older than 5
>> days. But i need data which is just 5 days old.
>>   I followed the following link
>> 
>> http://stackoverflow.com/questions/2539035/how-to-do-a-timestamp-comparison-with-jpa-query
>> 
>>    but still i am getting same problem. Any ideas on this.
>> 
>> 
>> Thanks
>> 
>> 
>> 

Reply via email to