I dont now how to compare date and time portion in a grails query. I use Mysql and grails 2.3.8. My domain class has two Date type properties and DATETIME Types in Mysql. Then I need to execute a sql query (criteria,createcriteria...etc) with the date or time part.
f1 > initialdate , here i need only the date part (yyyy-MM-dd)
and other query
f1 > inititaldate, here i need only the time part (HH:mm)
I am getting inconsistent results:
def resultado = Reservacion.where {
year(fhfinal) == reservacionInstance.fhinicio.toCalendar().get(Calendar.YEAR)
&&
month(fhfinal) == reservacionInstance.fhinicio.toCalendar().get(Calendar.MOTH)
}.list()
MYSQL:Time(0) in database
date_format(domainname_.propertiename,'%Y-%m-%d')
date_format(domainname_.propertiename,'%k:%i')
It is working but I'd like using HQL
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.