I have problem with timestamp in JPA query.
I wonna select all data from database where difference between two
timestamps is more than 2 month.
Database:
ID timestamp1 timestamp2
1 20008-11-19 15:02000 20008-08-19 15:02000
2 20008-11-19 15:02000 20008-11-14 15:02000
......
@Column(name = "timestamp1", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
public Date timestamp1;
@Column(name = "timestamp2", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
public Date timestamp2;
........
sql query works:
select id from table where
MONTH( DATE(timestamp1) - DATE(timestamp2) ) > 3
........
but how I can write in Java?
I't doesnt wrk:
Query query = em.createQuery("SELECT id FROM table WHERE MONTH(
DATE(timestamp1) - DATE(timestamp2) ) > 3 ")
--
View this message in context:
http://n2.nabble.com/Timestamp-tp1557213p1557213.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.