java - Returning records from database between two dates -


i've created program using java connects database , allows user submit record. record includes unique reference number , started date (variable: starteddate).

i want enable user search amount of cases submitted between 2 dates (the first day of month , todays date).

so far have sql query

select * cases startdate>'***' , date<'****' 

in java, be

select * cases starteddate>'1stmonthdate' , date<'todaysdate' 

my first question - within database, there isn't field called "date" have change on daily basis. how reference automatically generated date java?

also, how implement count() method return int of number of records returned?

select * cases starteddate between :startdate , :enddate 

in jpql:

public list<cases> findallevents(date startdate, date enddate) {       list<cases> allcases = entitymanager.createquery("select * cases starteddate between :startdate , :enddate")     .setparameter("startdate", startdate, temporaltype.date)     .setparameter("enddate", enddate, temporaltype.date)     .getresultlist();         return allcases ;       } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -