Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Not able to extract data for the datatype Timestamp

Dear Friends

I am not able to extract data from the table on the field with data type timestamp. Following is the scenario in which i am working ,

I have a session bean where i am trying to retrieve all the records for a particular date .the field on which I am firing the query is "lastmodifiedat" and I am using the following query to extract data

Select e from HsSiteHeader e where (e.lastmodifiedat >= ?1 and e.lastmodifiedat <= ?2) and e.hsspcode = '8013'

here HsSiteHeader is the name of entity class and in the session bean i am setting the query parameters through this piece of code

Calendar requiredDate = Calendar.getInstance();

requiredDate.set(Calendar.DATE,requiredDate.get(Calendar.DATE)-4);

Date theDate = new Date(requiredDate.getTimeInMillis());

Timestamp dateForTestTimestamp = new Timestamp(theDate.getTime());

Calendar requiredDate2 = Calendar.getInstance();

requiredDate.set(Calendar.DATE,requiredDate.get(Calendar.DATE)-3);

Date theDate2 = new Date(requiredDate.getTimeInMillis());

Timestamp dateForTestTimestamp 2= new Timestamp(theDate2.getTime());

Query query = em.createQuery("Select e from HsSiteHeader e where (e.lastmodifiedat >= ?1 and e.lastmodifiedat <= ?2) and e.hsspcode = '8013'");

query.setParameter(1,dateForTestTimestamp);

query.setParameter(2,dateForTestTimestamp2);

but this logic is nt working out

and I am not able to retrieve records from the database though there are records that match the criteria

Does any one has an idea how to operate with timestamp datatype

Former Member
Not what you were looking for? View more on this topic or Ask a question